cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: FFTW 3.3.8: Complex numbers cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167:
cannam@167:

cannam@167: Next: , Previous: , Up: Data Types and Files   [Contents][Index]

cannam@167:
cannam@167:
cannam@167: cannam@167:

4.1.1 Complex numbers

cannam@167: cannam@167:

The default FFTW interface uses double precision for all cannam@167: floating-point numbers, and defines a fftw_complex type to hold cannam@167: complex numbers as: cannam@167:

cannam@167:
cannam@167:
typedef double fftw_complex[2];
cannam@167: 
cannam@167: cannam@167: cannam@167:

Here, the [0] element holds the real part and the [1] cannam@167: element holds the imaginary part. cannam@167:

cannam@167:

Alternatively, if you have a C compiler (such as gcc) that cannam@167: supports the C99 revision of the ANSI C standard, you can use C’s new cannam@167: native complex type (which is binary-compatible with the typedef above). cannam@167: In particular, if you #include <complex.h> before cannam@167: <fftw3.h>, then fftw_complex is defined to be the native cannam@167: complex type and you can manipulate it with ordinary arithmetic cannam@167: (e.g. x = y * (3+4*I), where x and y are cannam@167: fftw_complex and I is the standard symbol for the cannam@167: imaginary unit); cannam@167: cannam@167:

cannam@167: cannam@167:

C++ has its own complex<T> template class, defined in the cannam@167: standard <complex> header file. Reportedly, the C++ standards cannam@167: committee has recently agreed to mandate that the storage format used cannam@167: for this type be binary-compatible with the C99 type, i.e. an array cannam@167: T[2] with consecutive real [0] and imaginary [1] cannam@167: parts. (See report cannam@167: http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2002/n1388.pdf cannam@167: WG21/N1388.) Although not part of the official standard as of this cannam@167: writing, the proposal stated that: “This solution has been tested with cannam@167: all current major implementations of the standard library and shown to cannam@167: be working.” To the extent that this is true, if you have a variable cannam@167: complex<double> *x, you can pass it directly to FFTW via cannam@167: reinterpret_cast<fftw_complex*>(x). cannam@167: cannam@167: cannam@167:

cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: