cannam@127: cannam@127: cannam@127: cannam@127: cannam@127:
cannam@127:cannam@127: Next: One-Dimensional DFTs of Real Data, Previous: Complex One-Dimensional DFTs, Up: Tutorial [Contents][Index]
cannam@127:Multi-dimensional transforms work much the same way as one-dimensional
cannam@127: transforms: you allocate arrays of fftw_complex
(preferably
cannam@127: using fftw_malloc
), create an fftw_plan
, execute it as
cannam@127: many times as you want with fftw_execute(plan)
, and clean up
cannam@127: with fftw_destroy_plan(plan)
(and fftw_free
).
cannam@127:
FFTW provides two routines for creating plans for 2d and 3d transforms, cannam@127: and one routine for creating plans of arbitrary dimensionality. cannam@127: The 2d and 3d routines have the following signature: cannam@127:
fftw_plan fftw_plan_dft_2d(int n0, int n1, cannam@127: fftw_complex *in, fftw_complex *out, cannam@127: int sign, unsigned flags); cannam@127: fftw_plan fftw_plan_dft_3d(int n0, int n1, int n2, cannam@127: fftw_complex *in, fftw_complex *out, cannam@127: int sign, unsigned flags); cannam@127:
These routines create plans for n0
by n1
two-dimensional
cannam@127: (2d) transforms and n0
by n1
by n2
3d transforms,
cannam@127: respectively. All of these transforms operate on contiguous arrays in
cannam@127: the C-standard row-major order, so that the last dimension has the
cannam@127: fastest-varying index in the array. This layout is described further in
cannam@127: Multi-dimensional Array Format.
cannam@127:
FFTW can also compute transforms of higher dimensionality. In order to cannam@127: avoid confusion between the various meanings of the the word cannam@127: “dimension”, we use the term rank cannam@127: cannam@127: to denote the number of independent indices in an array.2 For cannam@127: example, we say that a 2d transform has rank 2, a 3d transform has cannam@127: rank 3, and so on. You can plan transforms of arbitrary rank by cannam@127: means of the following function: cannam@127:
cannam@127:fftw_plan fftw_plan_dft(int rank, const int *n, cannam@127: fftw_complex *in, fftw_complex *out, cannam@127: int sign, unsigned flags); cannam@127:
Here, n
is a pointer to an array n[rank]
denoting an
cannam@127: n[0]
by n[1]
by … by n[rank-1]
transform.
cannam@127: Thus, for example, the call
cannam@127:
fftw_plan_dft_2d(n0, n1, in, out, sign, flags); cannam@127:
is equivalent to the following code fragment: cannam@127:
int n[2]; cannam@127: n[0] = n0; cannam@127: n[1] = n1; cannam@127: fftw_plan_dft(2, n, in, out, sign, flags); cannam@127:
fftw_plan_dft
is not restricted to 2d and 3d transforms,
cannam@127: however, but it can plan transforms of arbitrary rank.
cannam@127:
You may have noticed that all the planner routines described so far
cannam@127: have overlapping functionality. For example, you can plan a 1d or 2d
cannam@127: transform by using fftw_plan_dft
with a rank
of 1
cannam@127: or 2
, or even by calling fftw_plan_dft_3d
with n0
cannam@127: and/or n1
equal to 1
(with no loss in efficiency). This
cannam@127: pattern continues, and FFTW’s planning routines in general form a
cannam@127: “partial order,” sequences of
cannam@127:
cannam@127: interfaces with strictly increasing generality but correspondingly
cannam@127: greater complexity.
cannam@127:
fftw_plan_dft
is the most general complex-DFT routine that we
cannam@127: describe in this tutorial, but there are also the advanced and guru interfaces,
cannam@127:
cannam@127:
cannam@127: which allow one to efficiently combine multiple/strided transforms
cannam@127: into a single FFTW plan, transform a subset of a larger
cannam@127: multi-dimensional array, and/or to handle more general complex-number
cannam@127: formats. For more information, see FFTW Reference.
cannam@127:
The cannam@127: term “rank” is commonly used in the APL, FORTRAN, and Common Lisp cannam@127: traditions, although it is not so common in the C world.
cannam@127:cannam@127: Next: One-Dimensional DFTs of Real Data, Previous: Complex One-Dimensional DFTs, Up: Tutorial [Contents][Index]
cannam@127: