Problem casting STL complex to fftw_complex

前端 未结 3 1603
鱼传尺愫
鱼传尺愫 2020-12-28 08:25

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:

<
3条回答
  •  既然无缘
    2020-12-28 09:03

    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);
    ....
    

提交回复
热议问题