Inverse FFT

Hello @ all,

can someone give me a hint, how i can do the inverse FFT. Maybe someone can explain it to me using the tutorial FFT.C

thanks in advance

Jens

Hello Jens,

What do you want to transform, a histogram or an array? If it’s an array, you may want to look at the documentation of the TVirtualFFT class. If it’s a histogram, I assume you first make an FFT of the histogram and then want to make a backward transform?

Please clarify that and I’ll be happy to help you further.
Anna

Hello Anna,

you’re right… I make a FFT of the histogram… exactly like you did it in your tutorial… what I got is a histogram of the Fourier Spectra… may be then a stupid question…“where” is imagniary part of the result? (default option is R2C isn’t it?) … then the next question: if I have the fourier data what must i do to do the back transformation to the original data, in the way, that i get a histogram like the one i started with. If i read the reference guide it’s not clear for me, what i have to do if i have the fourier histogramm and want to come back to the starting point.
hm… in other words… what i do with my data is more or less the same as you do in the tutorial… first data in form of a histogram, make a fft with the “MAG” option… getting fourier histogram … later i will do some cuts on the fourier data and then the ifft a look for the changes compared to the original data…

puh… i hope i didn’t waste your time… have a nice weekend

Jens

If you make a transform of a histogram, you, generally speaking, have two objects back: the new histogram and the transform object itself. It can be retrieved (after making the transform) by calling

You can then get the real and complex part of the result by calling

fft->GetPointsComplex(re, im);, where re and im are big enough arrays. Do something with those arrays (cuts, or whatever you want), and then create a new transform object:

TVirtualFFT *fft2 = TVirtualFFT::FFT(1, &n, "C2R M K"); fft2->SetPointsComplex(re, im); fft2->Transform();
To get a magnitude or ph histogram of this transform, you can use

I hope this makes it a bit more understandable. Please try and let me know if it works for you.

Cheers,
Anna

Hi Anna,

so I tried to produce an iFFT with your help, but I get the following error:

Processing FFT_Back.C... Error: Can't call TVirtualFFT::GetPointsComplex(re,im) in current scope FFT_Back.C:64: Possible candidates are... public: virtual void TVirtualFFT::GetPointsComplex(Double_t* re,Double_t* im,Bool_t fromInput=kFALSE) const=0; public: virtual void TVirtualFFT::GetPointsComplex(Double_t* data,Bool_t fromInput=kFALSE) const=0; *** Interpreter error recovered ***

You can find my code in the attachment. Maybe you can tell me (…hm… I’m sure you can :smiley: ), what I’m doing wrong…

Thanks a lot

Jens
FFT_Back.C (1.74 KB)

Hi Jens,

As you are trying to get the complete output (GetPointsComplex(), not GetPointComplex), re and im should be big enough arrays of doubles, not just doubles.

Cheers,
Anna

Hi Anna,

thank you very much, it works!.. but one more question: if one do the FFT and iFFT respectively the “normalisation to the number of bins” is missing, means if I have sin(x) and do the iFFT and use for the sin(x) a histogramm with 1000 bins, I get in the back transformed histogram not a amplitude of 1 but of 1000 (in the FFT-histogram with the MAG output then number is sqrt(1000) to high) . Is their a option to make the “right normalisation” or have i do it manually?

anyway: Thanks again for your help!

Jens

Glad to hear it works for you now. But I’m afraid there is no automatic re-normalization, since the underlying fftw doesn’t have it, and I didn’t want to deviate from its behaviour. I’ll think of adding it in future, if you believe it might be needed by users.

Hi Anna,

may be it’s not really needed, but it could be confusing if one don’t recognise it and wonders why the result is not fitting in magnitude (especially if one is not experienced with FFT and is just trying without looking at the theory of Fourier Transformation). I think a short note in the reference guide and/or the tutorial is enough… hm… may be you can also include the back transformation in your tutorial or I can send you my corrected macro.

so, thank you again for your time and your great help

Jens

That’s a very good idea, please send me your macro, and I’ll add it to the tutorial with more comments.

sorry, for answering so late… I still have to make some comments and the I will send it to you… I hope this is ok…

Hi Jens!
I am waiting eagerly for this nice amendment of the tutorial macro. You would help me a great deal if you could post it. With or without comments.

Thanks a lot!

Tobias

Hi Tobias,

The tutorial macro is coming soon. If you need any help meanwhile, feel free to ask.

Cheers,
Anna