5

FFT libraries such as FFTW or numpy.fft typically provide two functions fft() and ifft() (and special versions thereof for real valued input). Those functions appear to be defined such that

ifft(fft(X)) == X

and

fft(X) == constant_factor * reverse(ifft(X))

Are there any practical or technical reasons to consider when choosing between ifft() and fft() operating on complex input? While the interpretations of X (signal, time or space domain) and fft(X) (spectrum, frequency domain) are different, does it ever matter computationally?

Jan
  • 723
  • 1
  • 11
  • 24

1 Answers1

6

Different fft libraries put the scaling constant in different places, in the fft, ifft or 1/sqrt(N) in both. So that's only a minor implementation dependent difference. The fft and the ifft reverse the order of their results. So that's only a difference between indexing forwards or backwards in you result array. Whether you call one time/space versus frequency is only a labeling difference.

So practically, pick the one where whatever scale the library uses and the direction you want to index your results produces the most readable code. Usually the fft/ifft libraries are set up so that one can index positive time and higher frequency in the same direction (++).

ADDED: Minor, probably unnecessary optimization: if you need to post-scale the FT results anyway, then pick the fft or ifft implementation that doesn't include a built-in scale multiply, as this may save N semi-redundant multiply operations.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Aren't the twiddle factors different for forward/inverse FFT ? From memory I think the sign changes on the imaginary part ? – Paul R Oct 13 '11 at 07:19
  • 1
    Changing the signs in some twiddle factors is what "reverses time" or outputs a result vector with the opposite indexing direction. – hotpaw2 Oct 13 '11 at 17:16
  • OK - thanks - I'd never really considered the possibility that the FFT and IFFT might be interchangeable in this way - I'll have to look into this further, if only for curiosity's sake. – Paul R Oct 13 '11 at 18:38
  • so technically, if the fft was implemented with 1/sqrt(N), then `fft(fft(array))` would return the reverse array? Correct me if im wrong – Rik Schaaf Sep 10 '17 at 14:22
  • fft(fft()) would reverse the array, usually symmetric around element 0, possible scaled, depending on implementation scaling, possibly including numerical rounding noise. Symmetry: the value in array element 0 should stay the same, depending on indexing (C vs. matlab, etc.). – hotpaw2 Dec 06 '18 at 14:39