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