cannam@127: cannam@127: cannam@127: cannam@127: cannam@127:
cannam@127:cannam@127: Next: Precision, Previous: Data Types and Files, Up: Data Types and Files [Contents][Index]
cannam@127:The default FFTW interface uses double
precision for all
cannam@127: floating-point numbers, and defines a fftw_complex
type to hold
cannam@127: complex numbers as:
cannam@127:
typedef double fftw_complex[2]; cannam@127:
Here, the [0]
element holds the real part and the [1]
cannam@127: element holds the imaginary part.
cannam@127:
Alternatively, if you have a C compiler (such as gcc
) that
cannam@127: supports the C99 revision of the ANSI C standard, you can use C’s new
cannam@127: native complex type (which is binary-compatible with the typedef above).
cannam@127: In particular, if you #include <complex.h>
before
cannam@127: <fftw3.h>
, then fftw_complex
is defined to be the native
cannam@127: complex type and you can manipulate it with ordinary arithmetic
cannam@127: (e.g. x = y * (3+4*I)
, where x
and y
are
cannam@127: fftw_complex
and I
is the standard symbol for the
cannam@127: imaginary unit);
cannam@127:
cannam@127:
C++ has its own complex<T>
template class, defined in the
cannam@127: standard <complex>
header file. Reportedly, the C++ standards
cannam@127: committee has recently agreed to mandate that the storage format used
cannam@127: for this type be binary-compatible with the C99 type, i.e. an array
cannam@127: T[2]
with consecutive real [0]
and imaginary [1]
cannam@127: parts. (See report
cannam@127: http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2002/n1388.pdf
cannam@127: WG21/N1388.) Although not part of the official standard as of this
cannam@127: writing, the proposal stated that: “This solution has been tested with
cannam@127: all current major implementations of the standard library and shown to
cannam@127: be working.” To the extent that this is true, if you have a variable
cannam@127: complex<double> *x
, you can pass it directly to FFTW via
cannam@127: reinterpret_cast<fftw_complex*>(x)
.
cannam@127:
cannam@127:
cannam@127: