Incorrect result with both FFTW and MKL FFT

Incorrect result with both FFTW and MKL FFT

Hello everyone,

I've noticed that both MKL FFT and FFTW is giving me a wrong result while calculating 2D complex-to-complex BACKWARD FFT. I am attaching the source codes that I used on this forum to discuss it with the experts.

While the input array is :

 1.0+0.0i  1.0+0.0i  1.0+0.0i
 1.0+0.0i  1.0+0.0i  1.0+0.0i
 1.0+0.0i  1.0+0.0i  1.0+0.0i

The forward transform should be:

 9.0+0.0i  0.0+0.0i  0.0+0.0i
 0.0+0.0i  0.0+0.0i  0.0+0.0i
 0.0+0.0i  0.0+0.0i  0.0+0.0i

And the backward transform should be again the initial array. However, it is:

 9.0+0.0i  9.0+0.0i  9.0+0.0i
 9.0+0.0i  9.0+0.0i  9.0+0.0i
 9.0+0.0i  9.0+0.0i  9.0+0.0i

I attached my test code here. Could you pls. let me know why this is happening?

 

AttachmentSize
Downloadapplication/octet-stream dp_plan_dft_2d_test.f905.56 KB
Downloadapplication/octet-stream 2D_dft.f905.13 KB
3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I have noticed that there is a scale factor (\sigma) in the original formulation of Discrete Fast Fourier (DFT) approach as it is implemented in Intel MKL here:

https://software.intel.com/en-us/mkl-developer-reference-c-fourier-trans...

In the above example array, we need to divide the array to some scaling factor to obtain the exact initial array. How should we access to the value of the (\sigma) or the scaling factor?

Point 1: It seems that the scaling factor is "1" when it is the forward transform. However, it changes during the backward transform.

Point 2: The implemented FFT formulation in MATLAB does not include any scaling factor!

Best Reply

Hi vahid,

If you would like get inverse of forward, you have to set backward scale factor. For you case, please set bscale to 1.0 / real(L(1)*L(2)), the result would be correct. For 1D, make sure fscale*bscale=1/len. For 2D, make sure fscale*bscale=1/ (col*row). If you would like to get similar matlab result for forward & backward, please set fscale=1/col, and bscale=1/row.

Best regards,
Fiona

Leave a Comment

Please sign in to add a comment. Not a member? Join today