GNU Scientific Library – Reference Manual: Overview of complex data FFTs

Next: Radix-2 FFT routines for complex data, Previous: Mathematical Definitions, Up: Fast Fourier Transforms [Index]

### 16.2 Overview of complex data FFTs

The inputs and outputs for the complex FFT routines are packed arrays of floating point numbers. In a packed array the real and imaginary parts of each complex number are placed in alternate neighboring elements. For example, the following definition of a packed array of length 6,

    double x[3*2];
    gsl_complex_packed_array data = x;

can be used to hold an array of three complex numbers, `z[3]`, in the following way,

    data[0] = Re(z[0])
    data[1] = Im(z[0])
    data[2] = Re(z[1])
    data[3] = Im(z[1])
    data[4] = Re(z[2])
    data[5] = Im(z[2])

The array indices for the data have the same ordering as those in the definition of the DFT—i.e. there are no index transformations or permutations of the data.

A stride parameter allows the user to perform transforms on the elements `z[stride*i]` instead of `z[i]`. A stride greater than 1 can be used to take an in-place FFT of the column of a matrix. A stride of 1 accesses the array without any additional spacing between elements.

To perform an FFT on a vector argument, such as `gsl_vector_complex * v`, use the following definitions (or their equivalents) when calling the functions described in this chapter:

    gsl_complex_packed_array data = v->data;
    size_t stride = v->stride;
    size_t n = v->size;

For physical applications it is important to remember that the index appearing in the DFT does not correspond directly to a physical frequency. If the time-step of the DFT is \Delta then the frequency-domain includes both positive and negative frequencies, ranging from -1/(2\Delta) through 0 to +1/(2\Delta). The positive frequencies are stored from the beginning of the array up to the middle, and the negative frequencies are stored backwards from the end of the array.

Here is a table which shows the layout of the array data, and the correspondence between the time-domain data z, and the frequency-domain data x.

    index    z               x = FFT(z)

    0        z(t = 0)        x(f = 0)
    1        z(t = 1)        x(f = 1/(n Delta))
    2        z(t = 2)        x(f = 2/(n Delta))
    .        ........        ..................
    n/2      z(t = n/2)      x(f = +1/(2 Delta),
                                   -1/(2 Delta))
    .        ........        ..................
    n-3      z(t = n-3)      x(f = -3/(n Delta))
    n-2      z(t = n-2)      x(f = -2/(n Delta))
    n-1      z(t = n-1)      x(f = -1/(n Delta))

When n is even the location n/2 contains the most positive and negative frequencies (+1/(2 \Delta), -1/(2 \Delta)) which are equivalent. If n is odd then general structure of the table above still applies, but n/2 does not appear.

Next: Radix-2 FFT routines for complex data, Previous: Mathematical Definitions, Up: Fast Fourier Transforms [Index]