110 Basic quantum mechanics
in which each summation is now a DDFT of size N/2 [CG00, pp. 22–23]. Each
of the new summations can again be split into two summations of size N/4, and
we repeat this k times until N/k = 2, which is a trivial sum. The computational
gains obtained from using the FFT algorithm are significant. A conventional “brute
force” DDFT of a 1-D array with N = 2
n
entries takes of the order of N
2
float-
ing point operations. The FFT algorithm takes only N log
2
N = nN operations,
which represents a significant time saving factor: for N = 1024 we have n = 10
and hence the FFT takes of the order of 10 240 operations compared with 1048 576
for the naively implemented DDFT. For multi-dimensional discrete Fourier trans-
forms, the time saving factors are even larger. We will make extensive use of the
FFT in Chapters 7 and 10, when we talk about the multi-slice image simulation
method.
There are many different numerical implementations of this recursive algorithm.
The algorithm can be extended to arrays of arbitrary size N ; in such cases the trans-
form is decomposed into summations corresponding to N = 2
a
3
b
5
c
7
d
11
e
13
f
...,
in other words, N is decomposed into powers of prime numbers. While the FFT
algorithm is intuitively easy to understand, the reader is advised against attempting
to implement the algorithm him/herself; there are many commercial
and public do-
main implementations available, and most of them have been optimized for speed.
In fact, in a 1995 review article, Sorensen, Burrus, and Heideman [SBH95] list
more than 30 different implementations, and a total of about 3500 papers devoted
to FFTs, since their inception in 1965.
For a detailed description of the basic algorithm and its implementation we
refer to Numerical Recipes: The Art of Scientific Computing (FORTRAN Ver-
sion) [PFTV89], Section 12.2. There are several public domain implementations
available, among others the
fftpack library (www.netlib.org). The source code
in this book makes use of the
FFTW public domain library of FFT routines;
†
the
source code can be downloaded from
http://www.fftw.org. The library is easy
to install and test. Although all of the routines are written in C, the package provides
a set of wrapper-routines that convert the internal data to a column-based ordering,
so that Fortran programs can call all of the C routines. Instructions for installing the
FFTW library can be found on the website. The main reasons for using the FFTW
library are its speed, and the fact that the algorithm automatically selects the best
decomposition of N into prime numbers, so that the restriction N = 2
n
, common
to many implementations, is not present. This will become useful in later chapters,
where we will need to compute FFTs of arrays for which the dimensions are not
simple powers of 2.
†
FFTW was written by Matteo Frigo and Steven G. Johnson. The source code is included on the website under
the GNU General Public Licence.