Search code examples
c++mathfftspectrumifft

Inverse fast fourier transform: different phases


RosettaCode gives a simple implementation of the Cooley–Tukey FFT algorithm here. The question is the following and is from a mathematical and programming point of view. Suppose that an input of a program is the spectrum of a signal, and we want to generate a signal which has such a spectrum. If am correct, we need to take the inverse FFT of the input spectrum.

The code given by RosettaCode is the following:

// inverse fft (in-place)
void ifft(CArray& x)
{
    // conjugate the complex numbers
    x = x.apply(std::conj);

    // forward fft
    fft( x );

    // conjugate the complex numbers again
    x = x.apply(std::conj);

    // scale the numbers
    x /= x.size();
}

But this can only generate one signal. But several signals can have the same spectrum. So how to add a parameter to be able to generate these different signals?


Solution

  • No, different signals have different Fourier transforms; it is invertible. N complex numbers in, N complex numbers out; the discrete Fourier transform amounts to multiplying a vector of samples by a nonsingular matrix, getting a vector of the same size.

    You might be confusing an actual Fourier transform with a "spectrum" obtained taking the magnitude of the Fourier transform or with the result of other information-destroying operations.