10 #ifndef EIGEN_FFT_MODULE_H
11 #define EIGEN_FFT_MODULE_H
16 #include "../../Eigen/Core"
80 #include "../../Eigen/src/Core/util/DisableStupidWarnings.h"
84 #ifdef EIGEN_FFTW_DEFAULT
90 template <
typename T>
struct default_fft_impl :
public internal::fftw_impl<T> {};
92 #elif defined EIGEN_MKL_DEFAULT
96 template <
typename T>
struct default_fft_impl :
public internal::imklfft::imklfft_impl<T> {};
98 #elif defined EIGEN_POCKETFFT_DEFAULT
100 # include<pocketfft_hdronly.h>
103 template <
typename T>
104 struct default_fft_impl :
public internal::pocketfft_impl<T> {};
110 template <
typename T>
121 template<
typename T_SrcMat,
typename T_FftIfc>
struct fft_fwd_proxy;
122 template<
typename T_SrcMat,
typename T_FftIfc>
struct fft_inv_proxy;
125 template<
typename T_SrcMat,
typename T_FftIfc>
126 struct traits< fft_fwd_proxy<T_SrcMat,T_FftIfc> >
128 typedef typename T_SrcMat::PlainObject ReturnType;
130 template<
typename T_SrcMat,
typename T_FftIfc>
131 struct traits< fft_inv_proxy<T_SrcMat,T_FftIfc> >
133 typedef typename T_SrcMat::PlainObject ReturnType;
137 template<
typename T_SrcMat,
typename T_FftIfc>
145 template<
typename T_DestMat>
void evalTo(T_DestMat& dst)
const;
155 template<
typename T_SrcMat,
typename T_FftIfc>
163 template<
typename T_DestMat>
void evalTo(T_DestMat& dst)
const;
174 template <
typename T_Scalar,
181 typedef typename impl_type::Scalar
Scalar;
207 m_impl.fwd(dst,src,
static_cast<int>(nfft));
215 m_impl.fwd(dst,src,
static_cast<int>(nfft));
218 #if defined EIGEN_FFTW_DEFAULT || defined EIGEN_POCKETFFT_DEFAULT || defined EIGEN_MKL_DEFAULT
222 m_impl.fwd2(dst,src,n0,n1);
226 template <
typename Input_>
228 void fwd( std::vector<Complex> & dst,
const std::vector<Input_> & src)
231 dst.resize( (src.size()>>1)+1);
233 dst.resize(src.size());
234 fwd(&dst[0],&src[0],src.size());
237 template<
typename InputDerived,
typename ComplexDerived>
241 typedef typename ComplexDerived::Scalar dst_type;
242 typedef typename InputDerived::Scalar src_type;
247 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
249 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
255 dst.
derived().resize( (nfft>>1)+1);
261 if (src.
size()<nfft) {
263 tmp.block(0,0,src.
size(),1 ) = src;
267 fwd( &dst[0],&tmp[0],nfft );
269 fwd( &dst[0],&src[0],nfft );
273 template<
typename InputDerived>
281 template<
typename InputDerived>
292 m_impl.inv( dst,src,
static_cast<int>(nfft) );
300 m_impl.inv( dst,src,
static_cast<int>(nfft) );
305 template<
typename OutputDerived,
typename ComplexDerived>
309 typedef typename ComplexDerived::Scalar src_type;
310 typedef typename ComplexDerived::RealScalar real_type;
311 typedef typename OutputDerived::Scalar dst_type;
317 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
319 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
323 nfft = 2*(src.
size()-1);
331 ? ( (nfft/2+1) - src.
size() )
332 : ( nfft - src.
size() );
337 if ( resize_input ) {
342 tmp.head(ncopy) = src.head(ncopy);
343 tmp(ncopy-1) =
real(tmp(ncopy-1));
348 tmp.head(nhead) = src.head(nhead);
349 tmp.tail(ntail) = src.tail(ntail);
350 if (resize_input<0) {
351 tmp(nhead) = ( src(nfft/2) + src( src.
size() - nfft/2 ) )*real_type(.5);
353 tmp(nhead) = src(nhead) * real_type(.5);
354 tmp(tmp.
size()-nhead) = tmp(nhead);
360 inv( &dst[0],&tmp[0], nfft);
362 inv( &dst[0],&src[0], nfft);
366 template <
typename Output_>
368 void inv( std::vector<Output_> & dst,
const std::vector<Complex> & src,
Index nfft=-1)
373 inv( &dst[0],&src[0],nfft);
377 #if defined EIGEN_FFTW_DEFAULT || defined EIGEN_POCKETFFT_DEFAULT || defined EIGEN_MKL_DEFAULT
381 m_impl.inv2(dst,src,n0,n1);
383 scale(dst,1./(n0*n1),n0*n1);
392 template <
typename T_Data>
397 for (
int k=0;k<nx;++k)
400 if ( ((ptrdiff_t)
x) & 15 )
412 Index nhbins=(nfft>>1)+1;
413 for (
Index k=nhbins;k < nfft; ++k )
414 freq[k] =
conj(freq[nfft-k]);
421 template<
typename T_SrcMat,
typename T_FftIfc>
422 template<
typename T_DestMat>
inline
425 m_ifc.fwd( dst, m_src, m_nfft);
428 template<
typename T_SrcMat,
typename T_FftIfc>
429 template<
typename T_DestMat>
inline
432 m_ifc.inv( dst, m_src, m_nfft);
437 #include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"
#define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0, TYPE1)
#define EIGEN_STATIC_ASSERT(X, MSG)
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
void fwd(std::vector< Complex > &dst, const std::vector< Input_ > &src)
static constexpr Flag HalfSpectrum
void fwd(Complex *dst, const Complex *src, Index nfft)
fft_fwd_proxy< MatrixBase< InputDerived >, FFT< T_Scalar, T_Impl > > fwd(const MatrixBase< InputDerived > &src, Index nfft=-1)
static constexpr Flag Speedy
void fwd(Complex *dst, const Scalar *src, Index nfft)
void inv(Scalar *dst, const Complex *src, Index nfft)
void inv(MatrixBase< OutputDerived > &dst, const MatrixBase< ComplexDerived > &src, Index nfft=-1)
void fwd(MatrixBase< ComplexDerived > &dst, const MatrixBase< InputDerived > &src, Index nfft=-1)
FFT(const impl_type &impl=impl_type(), Flag flags=Default)
impl_type::Complex Complex
void scale(T_Data *x, Scalar s, Index nx)
static constexpr Flag Unscaled
bool HasFlag(Flag f) const
fft_inv_proxy< MatrixBase< InputDerived >, FFT< T_Scalar, T_Impl > > inv(const MatrixBase< InputDerived > &src, Index nfft=-1)
static constexpr Flag Default
void ReflectSpectrum(Complex *freq, Index nfft)
void inv(Complex *dst, const Complex *src, Index nfft)
void inv(std::vector< Output_ > &dst, const std::vector< Complex > &src, Index nfft=-1)
Matrix< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ > & setZero(Index rows, Index cols)
static ConstMapType Map(const Scalar *data)
static ConstAlignedMapType MapAligned(const Scalar *data)
const unsigned int DirectAccessBit
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_real_op< typename Derived::Scalar >, const Derived > real(const Eigen::ArrayBase< Derived > &x)
void evalTo(T_DestMat &dst) const
fft_fwd_proxy(const T_SrcMat &src, T_FftIfc &fft, Index nfft)
void evalTo(T_DestMat &dst) const
fft_inv_proxy(const T_SrcMat &src, T_FftIfc &fft, Index nfft)