New adaptor for fftw_complex to C++ complex

This commit is contained in:
Guilhem Lavaux 2015-06-07 10:44:43 +02:00
parent ddaac4a97a
commit 209dfec2b4

View File

@ -0,0 +1,42 @@
#ifndef __COSMOTOOL_FFT_COMPLEX_HPP
#define __COSMOTOOL_FFT_COMPLEX_HPP
#include <complex>
#include <fftw3.h>
namespace CosmoTool
{
template<typename T>
struct adapt_complex {
};
template<> struct adapt_complex<fftw_complex> {
typedef fftw_complex f_type;
typedef std::complex<double> cpp_complex;
static inline cpp_complex *adapt(f_type *a) {
return reinterpret_cast<cpp_complex *>(a);
}
};
template<> struct adapt_complex<fftwf_complex> {
typedef fftwf_complex f_type;
typedef std::complex<float> cpp_complex;
static inline cpp_complex *adapt(f_type *a) {
return reinterpret_cast<cpp_complex *>(a);
}
};
template<> struct adapt_complex<fftwl_complex> {
typedef fftwl_complex f_type;
typedef std::complex<long double> cpp_complex;
static inline cpp_complex *adapt(f_type *a) {
return reinterpret_cast<cpp_complex *>(a);
}
};
}
#endif