Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6621 Discussions

## Incorrect result with both FFTW and MKL FFT Beginner
435 Views

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?

1 Solution Employee
435 Views

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

2 Replies Beginner
435 Views

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-transform-functions

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! Employee
436 Views

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 