35#include "../../meta/trueFalseT.hpp"
44#define MXFFT_FORWARD ( FFTW_FORWARD )
45#define MXFFT_BACKWARD ( FFTW_BACKWARD )
47template <
typename _inputT,
typename _outputT,
size_t _rank,
int _cudaGPU = 0>
51std::vector<int> fftwDimVec(
int szX,
int szY,
int szZ );
68template <
typename _inputT,
typename _outputT,
size_t _rank>
76 static const size_t rank =
_rank;
89 planT m_plan{
nullptr };
96 template <
int crank = _rank>
102 typename std::enable_if<crank == 1>::type * = 0 );
105 template <
int crank = _rank>
112 typename std::enable_if<crank == 2>::type * = 0 );
115 template <
int crank = _rank>
123 typename std::enable_if<crank == 3>::type * = 0 );
145 template <
int crank = _rank>
152 typename std::enable_if<crank == 1>::type * = 0 );
155 template <
int crank = _rank>
163 typename std::enable_if<crank == 2>::type * = 0 );
166 template <
int crank = _rank>
175 typename std::enable_if<crank == 3>::type * = 0 );
183template <
typename inputT,
typename outputT,
size_t rank>
184fftT<inputT, outputT, rank, 0>::fftT()
188template <
typename inputT,
typename outputT,
size_t rank>
190fftT<inputT, outputT, rank, 0>::fftT(
int nx,
int ndir,
bool inPlace,
typename std::enable_if<crank == 1>::type * )
197template <
typename inputT,
typename outputT,
size_t rank>
199fftT<inputT, outputT, rank, 0>::fftT(
200 int nx,
int ny,
int ndir,
bool inPlace,
typename std::enable_if<crank == 2>::type * )
207template <
typename inputT,
typename outputT,
size_t rank>
209fftT<inputT, outputT, rank, 0>::fftT(
210 int nx,
int ny,
int nz,
int ndir,
bool inPlace,
typename std::enable_if<crank == 3>::type * )
217template <
typename inputT,
typename outputT,
size_t rank>
218fftT<inputT, outputT, rank, 0>::~fftT()
223template <
typename inputT,
typename outputT,
size_t rank>
224void fftT<inputT, outputT, rank, 0>::destroyPlan()
235template <
typename inputT,
typename outputT,
size_t rank>
236int fftT<inputT, outputT, rank, 0>::dir()
241template <
typename inputT,
typename outputT,
size_t rank>
242void fftT<inputT, outputT, rank, 0>::doPlan(
const meta::trueFalseT<false> &
inPlace )
256 sz = m_szX * m_szY * m_szZ;
277template <
typename inputT,
typename outputT,
size_t rank>
278void fftT<inputT, outputT, rank, 0>::doPlan(
const meta::trueFalseT<true> &
inPlace )
291 sz = m_szX * m_szY * m_szZ;
304 reinterpret_cast<inputT *
>(
forplan ),
305 reinterpret_cast<outputT *
>(
forplan ),
313template <
typename inputT,
typename outputT,
size_t rank>
315void fftT<inputT, outputT, rank, 0>::plan(
int nx,
int ndir,
bool inPlace,
typename std::enable_if<crank == 1>::type * )
317 if( m_szX == nx && m_dir ==
ndir && m_plan )
332 doPlan( meta::trueFalseT<false>() );
336 doPlan( meta::trueFalseT<true>() );
340template <
typename inputT,
typename outputT,
size_t rank>
342void fftT<inputT, outputT, rank, 0>::plan(
343 int nx,
int ny,
int ndir,
bool inPlace,
typename std::enable_if<crank == 2>::type * )
345 if( m_szX == nx && m_szY == ny && m_dir ==
ndir && m_plan )
360 doPlan( meta::trueFalseT<false>() );
364 doPlan( meta::trueFalseT<true>() );
368template <
typename inputT,
typename outputT,
size_t rank>
370void fftT<inputT, outputT, rank, 0>::plan(
371 int nx,
int ny,
int nz,
int ndir,
bool inPlace,
typename std::enable_if<crank == 3>::type * )
373 if( m_szX == nx && m_szY == ny && m_szZ ==
nz && m_dir ==
ndir && m_plan )
388 doPlan( meta::trueFalseT<false>() );
392 doPlan( meta::trueFalseT<true>() );
396template <
typename inputT,
typename outputT,
size_t rank>
397void fftT<inputT, outputT, rank, 0>::operator()( outputT *
out, inputT *
in )
const
403std::vector<int> fftwDimVec<1>(
int szX,
int szY,
int szZ );
406std::vector<int> fftwDimVec<2>(
int szX,
int szY,
int szZ );
409std::vector<int> fftwDimVec<3>(
int szX,
int szY,
int szZ );
414class fft<std::complex<float>, std::complex<float>, 2, 1>
429 fft(
int nx,
int ny )
437 void plan(
int nx,
int ny )
439 if( m_szX == nx && m_szY == ny )
447 cufftPlan2d( &m_plan, m_szX, m_szY, CUFFT_C2C );
450 void fwdFFT( std::complex<float> *in, std::complex<float> *out )
452 cufftExecC2C( m_plan, (cufftComplex *)in, (cufftComplex *)out, CUFFT_FORWARD );
Declares and defines templatized wrappers for the fftw library.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
fftwX_plan planT
Specializations typedef planT as fftwf_plan, fftw_plan, fftwl_plan, or fftwq_plan.
std::complex< realT > complexT
The complex data type.
_realT realT
The real data type (_realT is actually defined in specializations).