我正在将Python例程集成到C++代码中。
在Python中使用了一些实矩阵的fft 2D的计算。
F_BLK=np.fft.fft2(blk)F_BLK是一个复杂的512*24矩阵,系数复实,映射部分数量级为10e5。
在计算矩阵的fft2时,得到了一个复系数为的复矩阵,实部为10e6级,虚部为。
发布于 2014-08-18 09:56:05
- then you do not need to have so much calculations ( C += R \* C is simpler then C += C \* C)
- so if you have FFT C = f(R) coded for such input data then it is usually faster
- then standard FFT C= f(C)
- and also you do not need to have allocated memory for the input imaginary part
- also when input data is real only then the FFT output is symmetric
- so you can just compute only first half of output data and mirror the rest
- either you have wrong implementation of FFT (in python or in C++)
- or you just have different normalization coefficients
- plot the data and compare if the difference is just constant scale factor
- if not then you have bug in FFT implementation somewhere or the python FFT is not FFT
- also do not forget that data size for any FFT must be power of 2
- if your implementation expects that then also that could be the cause of error
- so try resize matrix 512x24 to 512x32 by zero padding before FFT
- another thing that can cause this can be overflow errors
- if you mix huge and small numbers together your accuracy get lost
- especially by FFT recursions the output magnitude can be 10e5 but the subresults can be much much bigger !!!
- look here [2D FFT,DCT by 1D FFT,DCT](https://stackoverflow.com/a/22779268/2521214)
- it contains slow 1D DFT,iDFT implementations in C++ (`R->C`,`C->R`)
- and algorithm how to compute 2D transforms with it
- with correct results so you can check yours
https://stackoverflow.com/questions/25359433
复制相似问题