9 Fast Fourier Transform

9.1 Overview

This toolbox uses C version of the Fortran FFTPack library available on http://www.netlib.org/fftpack.

The forward Fourier transform of a vector c is defined by

     N∑- 1   -ijk2π∕N
zj =     cke       ,  j = 0,⋅⋅⋅ ,N - 1
     k=0

The inverse Fourier transform enables to recover c from z and is defined by

       N∑- 1
ck = -1     ckeijk2π∕N,  j = 0,⋅⋅⋅ ,N - 1
    N  k=0

Note that the inverse Fourier transform is scaled by N1, such that the inverse Fourier transform applies to the Fourier transform just yields the original vector.

The coefficients of the Fourier transform of a real function satisfy the following relation

zk = zN-k,
(3)

where N is the number of discretization points.

A few remarks on the FFT of real functions and its inverse transform:

FFTPack storage The functions use the fftpack storage convention for half-complex sequences. In this convention, the half-complex transform of a real sequence is stored with frequencies in increasing order, starting from zero, with the real and imaginary parts of each frequency in neighboring locations.

The storage scheme is best shown by some examples. The table below shows the output for an odd-length sequence, n = 5. The two columns give the correspondence between the 5 values in the half-complex sequence (stored in a PnlVect V ) and the values (PnlVectComplex C) that would be returned if the same real input sequence were passed to pnl_fft as a complex sequence (with imaginary parts set to 0),

C(0) = V(0) + i0,
C(1) = V(1) + iV (2),
C(2) = V(3) + iV (4), -----
C(3) = V(3) - iV (4) = C-(2),
C(4) = V(1) + iV (2) = C (1)
(4)

The elements of index greater than N∕2 of the complex array, as C(3) and C(4) are filled in using the symmetry condition.

The next table shows the output for an even-length sequence, n = 6. In the even case, there are two values which are purely real,

C(0) = V(0) + i0,
C(1) = V(1) + iV (2),

C(2) = V(3) + iV (4),---
C(3) = V(5) - i0 = C (0),---
C(4) = V(3) - iV (4) = C-(2),
C(5) = V(1) + iV (2) = C (1)
(5)

9.2 Functions

To use the following functions, you should include pnl/pnl_fft.h.

9.2.1 Direct call functions

All FFT functions need some extra memory to perform their computations. This is automatically handled by all the functions but you can these repeatedly, for instance inside a Monte Carlo loop, you should allocate a workspace once and for all and use the same at every iteration. In this case, use the functions defined in Section 9.2.2.

9.2.2 Function with workspace