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

FFT forward and backward test

Bo_Q_
Beginner
761 Views

Hi,

I am testing the FFT routines in MKL library. Following the example code, I was able to do 1D forward FFT for an array input supplied by a text file. Then a backward FFT is performed and the result is saved in another text file. 

Theoretically, the output of the backward FFT should be the same as the input array. But what I get is not. The real part is scaled by n (number of points) and the imaginary part is pure zero.

The attached files are the code, input file and output file. Please help me through. Thanks.

 

Bo

0 Kudos
3 Replies
Evarist_F_Intel
Employee
761 Views

Hi,

At first, I want to say about scaling. If you perform Forward and then Backward DFT you will get source array scaled by N, where N is the size of the array. It is just a property of DFT. If you want to perform unitary DFT, I should set DFTI_FORWARD_SCALE and DFTI_BACKWARD_SCALE to 1/sqrt(N) using DftiSetValue. Another way to obtain source array without scaling is to set DFTI_BACKWARD_SCALE to 1/N, and that is it.

I tried to run your code and got the problem with reading the input array: the program reads real part, but doesn't read imaginary part (looks like the problem is in format reading and commas). If I either remove commas from INPUT.txt or replace [fortran] READ(10,'(E10.3, E10.3)') DR(I), DI(I) [/fortran] with [fortran] READ(10,*) DR(I), DI(I) [/fortran] everything goes fine

0 Kudos
Bo_Q_
Beginner
761 Views

Thanks! Really appreciate your help!

0 Kudos
Evarist_F_Intel
Employee
761 Views

You are welcome!

0 Kudos
Reply