FFT forward and backward test

FFT forward and backward test

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

AnhangGröße
Herunterladen DOFFT.for2.64 KB
Herunterladen INPUT.TXT226 Bytes
Herunterladen OUTPUT.TXT237 Bytes
4 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

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

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

Thanks! Really appreciate your help!

You are welcome!

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen