30#pragma GCC system_header
35#include "../../math/constants.hpp"
55template <
typename _inputT,
typename _outputT,
size_t _rank,
int _cudaGPU = 0>
88template <
typename _inputT,
typename _outputT,
size_t _rank>
89class mftT<_inputT, _outputT, _rank, 0>
91 typedef _inputT inputT;
92 typedef _outputT outputT;
98 static const size_t rank = _rank;
100 typedef Eigen::Array<inputT, -1, -1> eigenArrayInT;
101 typedef Eigen::Array<outputT, -1, -1> eigenArrayOutT;
103 typedef Eigen::Matrix<complexT, -1, -1> eigenMatrixT;
126 template <
size_t crank = _rank>
133 typename std::enable_if<crank == 1>::type * = 0 ) =
delete;
136 template <
size_t crank = _rank>
146 typename std::enable_if<crank == 2>::type * = 0 );
149 template <
size_t crank = _rank>
162 typename std::enable_if<crank == 3>::type * = 0 ) =
delete;
165 template <
size_t crank = _rank>
175 typename std::enable_if<crank == 2>::type * = 0 );
179 const eigenArrayInT &in )
const;
182template <
typename inputT,
typename outputT,
size_t rank>
183mftT<inputT, outputT, rank, 0>::mftT()
187template <
typename inputT,
typename outputT,
size_t rank>
188template <
size_t crank>
189mftT<inputT, outputT, rank, 0>::mftT(
190 int nx,
int ny,
dir ndir, realT xoff, realT yoff, realT osFac,
typename std::enable_if<crank == 2>::type * )
192 plan( nx, ny, ndir, xoff, yoff, osFac );
195template <
typename inputT,
typename outputT,
size_t rank>
196template <
size_t crank>
197void mftT<inputT, outputT, rank, 0>::plan(
198 int nx,
int ny,
dir ndir, realT xOff, realT yOff, realT osFac,
typename std::enable_if<crank == 2>::type * )
200 if(m_szX == nx && m_szY == ny && m_dir == ndir && m_xOff == xOff && m_yOff == yOff && m_osFac == osFac)
214 throw std::invalid_argument(
"MFT of non-square size is not implemented. nx must equal ny." );
218 m_dftR.resize( m_szX, m_szX );
219 m_dftC.resize( m_szX, m_szX );
222 realT osN = m_szX * m_osFac;
227 realT norm = 1.0 / ( m_szX * m_szY );
229 for(
int cc = 0; cc < m_szY; ++cc )
233 for(
int rr = 0; rr < m_szX; ++rr )
235 realT x = ( rr - m_xOff ) * ccx / osN;
241 x = rrx * ( cc - m_yOff ) / osN;
252 for(
int cc = 0; cc < m_szY; ++cc )
255 if( ccx > m_szY / 2 )
256 ccx = -1 * ( m_szY - ccx );
258 for(
int rr = 0; rr < m_szX; ++rr )
261 if( rrx > m_szX / 2 )
262 rrx = -1 * ( m_szX - rrx );
264 realT x = rrx * ( cc - m_xOff ) / osN;
268 x = ( rr - m_yOff ) * ccx / osN;
276template <
typename inputT,
typename outputT,
size_t rank>
277void mftT<inputT, outputT, rank, 0>::operator()( eigenArrayOutT &out,
const eigenArrayInT &in )
const
279 out = ( m_dftR * in.matrix() * m_dftC ).array();
Declares and defines templatized wrappers for the fftw library.
dir
Directions of the Fourier Transform.
@ forward
Specifies the forward transform.
T sign(T x)
The sign function.
constexpr T pi()
Get the value of pi.
std::complex< realT > complexT
The complex data type.
_realT realT
The real data type (_realT is actually defined in specializations).