FFT forward and backward test

FFT forward and backward test


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.



Downloadapplication/octet-stream DOFFT.for2.64 KB
Downloadtext/plain INPUT.TXT226 bytes
Downloadtext/plain OUTPUT.TXT237 bytes
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


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

 READ(10,'(E10.3, E10.3)') DR(I), DI(I) 
 READ(10,*) DR(I), DI(I) 
everything goes fine

Thanks! Really appreciate your help!

You are welcome!

Leave a Comment

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