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