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