The FFTW manual says that its fftw_complex
type is bit compatible to std::complex
class in STL. But that doesn\'t work for me:
The idea behind bit-compatibility of fftw_complex and C99 and C++ complex types is not that they can be easily created from one another, but that all functions in FFTW that take pointers to fftw_complex can also take pointers to c++ std::complex. Therefore the best approach is probably to use std::complex<> throughout your program and only convert pointers to these values when calling FFTW functions:
std::vector > a1, a2;
....
....
fftw_plan_dft(N, reinterpret_cast(&a1[0]),
reinterpret_cast(&a2[0]),
FFTW_FORWARD, FFTW_ESTIMATE);
....