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