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