16.3 Radix-2 FFT routines for complex data

The radix-2 algorithms described in this section are simple and compact,
although not necessarily the most efficient. They use the Cooley-Tukey
algorithm to compute in-place complex FFTs for lengths which are a power
of 2—no additional storage is required. The corresponding
self-sorting mixed-radix routines offer better performance at the
expense of requiring additional working space.

All the functions described in this section are declared in the header file gsl_fft_complex.h.

These functions compute forward, backward and inverse FFTs of length
n with stride stride, on the packed complex array data
using an in-place radix-2 decimation-in-time algorithm. The length of
the transform n is restricted to powers of two. For the
transform version of the function the sign argument can be
either forward (-1) or backward (+1).

The functions return a value of GSL_SUCCESS if no errors were
detected, or GSL_EDOM if the length of the data n is not a
power of two.

These are decimation-in-frequency versions of the radix-2 FFT functions.

Here is an example program which computes the FFT of a short pulse in a
sample of length 128. To make the resulting Fourier transform real the
pulse is defined for equal positive and negative times (-10
… 10), where the negative times wrap around the end of the
array.

Note that we have assumed that the program is using the default error
handler (which calls abort for any errors). If you are not using
a safe error handler you would need to check the return status of
gsl_fft_complex_radix2_forward.

The transformed data is rescaled by 1/\sqrt n so that it fits on
the same plot as the input. Only the real part is shown, by the choice
of the input data the imaginary part is zero. Allowing for the
wrap-around of negative times at t=128, and working in units of
k/n, the DFT approximates the continuum Fourier transform, giving
a modulated sine function.