Eigen::FFT< T_Scalar, T_Impl > Class Template Reference

Public Types

typedef impl_type::Complex Complex
 
using Flag = int
 
typedef T_Impl impl_type
 
typedef DenseIndex Index
 
typedef impl_type::Scalar Scalar
 

Public Member Functions

void ClearFlag (Flag f)
 
 FFT (const impl_type &impl=impl_type(), Flag flags=Default)
 
void fwd (Complex *dst, const Complex *src, Index nfft)
 
void fwd (Complex *dst, const Scalar *src, Index nfft)
 
template<typename InputDerived >
fft_fwd_proxy< MatrixBase< InputDerived >, FFT< T_Scalar, T_Impl > > fwd (const MatrixBase< InputDerived > &src, Index nfft=-1)
 
template<typename InputDerived , typename ComplexDerived >
void fwd (MatrixBase< ComplexDerived > &dst, const MatrixBase< InputDerived > &src, Index nfft=-1)
 
template<typename Input_ >
void fwd (std::vector< Complex > &dst, const std::vector< Input_ > &src)
 
bool HasFlag (Flag f) const
 
impl_typeimpl ()
 
void inv (Complex *dst, const Complex *src, Index nfft)
 
template<typename InputDerived >
fft_inv_proxy< MatrixBase< InputDerived >, FFT< T_Scalar, T_Impl > > inv (const MatrixBase< InputDerived > &src, Index nfft=-1)
 
template<typename OutputDerived , typename ComplexDerived >
void inv (MatrixBase< OutputDerived > &dst, const MatrixBase< ComplexDerived > &src, Index nfft=-1)
 
void inv (Scalar *dst, const Complex *src, Index nfft)
 
template<typename Output_ >
void inv (std::vector< Output_ > &dst, const std::vector< Complex > &src, Index nfft=-1)
 
void SetFlag (Flag f)
 

Static Public Attributes

static constexpr Flag Default
 
static constexpr Flag HalfSpectrum
 
static constexpr Flag Speedy
 
static constexpr Flag Unscaled
 

Private Member Functions

void ReflectSpectrum (Complex *freq, Index nfft)
 
template<typename T_Data >
void scale (T_Data *x, Scalar s, Index nx)
 

Private Attributes

int m_flag
 
impl_type m_impl
 

Detailed Description

template<typename T_Scalar, typename T_Impl = default_fft_impl<T_Scalar>>
class Eigen::FFT< T_Scalar, T_Impl >

Definition at line 176 of file FFT.

Member Typedef Documentation

◆ Complex

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
typedef impl_type::Complex Eigen::FFT< T_Scalar, T_Impl >::Complex

Definition at line 182 of file FFT.

◆ Flag

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
using Eigen::FFT< T_Scalar, T_Impl >::Flag = int

Definition at line 184 of file FFT.

◆ impl_type

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
typedef T_Impl Eigen::FFT< T_Scalar, T_Impl >::impl_type

Definition at line 179 of file FFT.

◆ Index

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
typedef DenseIndex Eigen::FFT< T_Scalar, T_Impl >::Index

Definition at line 180 of file FFT.

◆ Scalar

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
typedef impl_type::Scalar Eigen::FFT< T_Scalar, T_Impl >::Scalar

Definition at line 181 of file FFT.

Constructor & Destructor Documentation

◆ FFT()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
Eigen::FFT< T_Scalar, T_Impl >::FFT ( const impl_type impl = impl_type(),
Flag  flags = Default 
)
inline

Definition at line 190 of file FFT.

190  :m_impl(impl),m_flag(flags)
191  {
192  eigen_assert((flags == Default || flags == Unscaled || flags == HalfSpectrum || flags == Speedy) && "invalid flags argument");
193  }
#define eigen_assert(x)
static constexpr Flag HalfSpectrum
Definition: FFT:187
static constexpr Flag Speedy
Definition: FFT:188
impl_type & impl()
Definition: FFT:389
int m_flag
Definition: FFT:418
static constexpr Flag Unscaled
Definition: FFT:186
static constexpr Flag Default
Definition: FFT:185
impl_type m_impl
Definition: FFT:417

Member Function Documentation

◆ ClearFlag()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::ClearFlag ( Flag  f)
inline

Definition at line 202 of file FFT.

202 { m_flag &= (~(int)f);}

◆ fwd() [1/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::fwd ( Complex dst,
const Complex src,
Index  nfft 
)
inline

Definition at line 213 of file FFT.

214  {
215  m_impl.fwd(dst,src,static_cast<int>(nfft));
216  }

◆ fwd() [2/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::fwd ( Complex dst,
const Scalar src,
Index  nfft 
)
inline

Definition at line 205 of file FFT.

206  {
207  m_impl.fwd(dst,src,static_cast<int>(nfft));
208  if ( HasFlag(HalfSpectrum) == false)
209  ReflectSpectrum(dst,nfft);
210  }
bool HasFlag(Flag f) const
Definition: FFT:196
void ReflectSpectrum(Complex *freq, Index nfft)
Definition: FFT:409

◆ fwd() [3/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename InputDerived >
fft_fwd_proxy< MatrixBase<InputDerived>, FFT<T_Scalar,T_Impl> > Eigen::FFT< T_Scalar, T_Impl >::fwd ( const MatrixBase< InputDerived > &  src,
Index  nfft = -1 
)
inline

Definition at line 276 of file FFT.

277  {
278  return fft_fwd_proxy< MatrixBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
279  }

◆ fwd() [4/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename InputDerived , typename ComplexDerived >
void Eigen::FFT< T_Scalar, T_Impl >::fwd ( MatrixBase< ComplexDerived > &  dst,
const MatrixBase< InputDerived > &  src,
Index  nfft = -1 
)
inline

Definition at line 239 of file FFT.

240  {
241  typedef typename ComplexDerived::Scalar dst_type;
242  typedef typename InputDerived::Scalar src_type;
243  EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputDerived)
244  EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived)
245  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ComplexDerived,InputDerived) // size at compile-time
246  EIGEN_STATIC_ASSERT((internal::is_same<dst_type, Complex>::value),
247  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
248  EIGEN_STATIC_ASSERT(int(InputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit,
249  THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
250 
251  if (nfft<1)
252  nfft = src.size();
253 
255  dst.derived().resize( (nfft>>1)+1);
256  else
257  dst.derived().resize(nfft);
258 
259  if ( src.innerStride() != 1 || src.size() < nfft ) {
260  Matrix<src_type,1,Dynamic> tmp;
261  if (src.size()<nfft) {
262  tmp.setZero(nfft);
263  tmp.block(0,0,src.size(),1 ) = src;
264  }else{
265  tmp = src;
266  }
267  fwd( &dst[0],&tmp[0],nfft );
268  }else{
269  fwd( &dst[0],&src[0],nfft );
270  }
271  }
#define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0, TYPE1)
#define EIGEN_STATIC_ASSERT(X, MSG)
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
void fwd(Complex *dst, const Scalar *src, Index nfft)
Definition: FFT:205
const unsigned int DirectAccessBit

◆ fwd() [5/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename Input_ >
void Eigen::FFT< T_Scalar, T_Impl >::fwd ( std::vector< Complex > &  dst,
const std::vector< Input_ > &  src 
)
inline

Definition at line 228 of file FFT.

229  {
231  dst.resize( (src.size()>>1)+1); // half the bins + Nyquist bin
232  else
233  dst.resize(src.size());
234  fwd(&dst[0],&src[0],src.size());
235  }

◆ HasFlag()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
bool Eigen::FFT< T_Scalar, T_Impl >::HasFlag ( Flag  f) const
inline

Definition at line 196 of file FFT.

196 { return (m_flag & (int)f) == f;}

◆ impl()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
impl_type& Eigen::FFT< T_Scalar, T_Impl >::impl ( )
inline

Definition at line 389 of file FFT.

389 {return m_impl;}

◆ inv() [1/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::inv ( Complex dst,
const Complex src,
Index  nfft 
)
inline

Definition at line 290 of file FFT.

291  {
292  m_impl.inv( dst,src,static_cast<int>(nfft) );
293  if ( HasFlag( Unscaled ) == false)
294  scale(dst,Scalar(1./nfft),nfft); // scale the time series
295  }
void scale(T_Data *x, Scalar s, Index nx)
Definition: FFT:394
impl_type::Scalar Scalar
Definition: FFT:181

◆ inv() [2/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename InputDerived >
fft_inv_proxy< MatrixBase<InputDerived>, FFT<T_Scalar,T_Impl> > Eigen::FFT< T_Scalar, T_Impl >::inv ( const MatrixBase< InputDerived > &  src,
Index  nfft = -1 
)
inline

Definition at line 284 of file FFT.

285  {
286  return fft_inv_proxy< MatrixBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
287  }

◆ inv() [3/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename OutputDerived , typename ComplexDerived >
void Eigen::FFT< T_Scalar, T_Impl >::inv ( MatrixBase< OutputDerived > &  dst,
const MatrixBase< ComplexDerived > &  src,
Index  nfft = -1 
)
inline

Definition at line 307 of file FFT.

308  {
309  typedef typename ComplexDerived::Scalar src_type;
310  typedef typename ComplexDerived::RealScalar real_type;
311  typedef typename OutputDerived::Scalar dst_type;
312  const bool realfft= (NumTraits<dst_type>::IsComplex == 0);
313  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OutputDerived)
314  EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived)
315  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ComplexDerived,OutputDerived) // size at compile-time
316  EIGEN_STATIC_ASSERT((internal::is_same<src_type, Complex>::value),
317  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
318  EIGEN_STATIC_ASSERT(int(OutputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit,
319  THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
320 
321  if (nfft<1) { //automatic FFT size determination
322  if ( realfft && HasFlag(HalfSpectrum) )
323  nfft = 2*(src.size()-1); //assume even fft size
324  else
325  nfft = src.size();
326  }
327  dst.derived().resize( nfft );
328 
329  // check for nfft that does not fit the input data size
330  Index resize_input= ( realfft && HasFlag(HalfSpectrum) )
331  ? ( (nfft/2+1) - src.size() )
332  : ( nfft - src.size() );
333 
334  if ( src.innerStride() != 1 || resize_input ) {
335  // if the vector is strided, then we need to copy it to a packed temporary
336  Matrix<src_type,1,Dynamic> tmp;
337  if ( resize_input ) {
338  size_t ncopy = (std::min)(src.size(),src.size() + resize_input);
339  tmp.setZero(src.size() + resize_input);
340  if ( realfft && HasFlag(HalfSpectrum) ) {
341  // pad at the Nyquist bin
342  tmp.head(ncopy) = src.head(ncopy);
343  tmp(ncopy-1) = real(tmp(ncopy-1)); // enforce real-only Nyquist bin
344  }else{
345  size_t nhead,ntail;
346  nhead = 1+ncopy/2-1; // range [0:pi)
347  ntail = ncopy/2-1; // range (-pi:0)
348  tmp.head(nhead) = src.head(nhead);
349  tmp.tail(ntail) = src.tail(ntail);
350  if (resize_input<0) { //shrinking -- create the Nyquist bin as the average of the two bins that fold into it
351  tmp(nhead) = ( src(nfft/2) + src( src.size() - nfft/2 ) )*real_type(.5);
352  }else{ // expanding -- split the old Nyquist bin into two halves
353  tmp(nhead) = src(nhead) * real_type(.5);
354  tmp(tmp.size()-nhead) = tmp(nhead);
355  }
356  }
357  }else{
358  tmp = src;
359  }
360  inv( &dst[0],&tmp[0], nfft);
361  }else{
362  inv( &dst[0],&src[0], nfft);
363  }
364  }
fft_inv_proxy< MatrixBase< InputDerived >, FFT< T_Scalar, T_Impl > > inv(const MatrixBase< InputDerived > &src, Index nfft=-1)
Definition: FFT:284
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_real_op< typename Derived::Scalar >, const Derived > real(const Eigen::ArrayBase< Derived > &x)

◆ inv() [4/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::inv ( Scalar dst,
const Complex src,
Index  nfft 
)
inline

Definition at line 298 of file FFT.

299  {
300  m_impl.inv( dst,src,static_cast<int>(nfft) );
301  if ( HasFlag( Unscaled ) == false)
302  scale(dst,Scalar(1./nfft),nfft); // scale the time series
303  }

◆ inv() [5/5]

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename Output_ >
void Eigen::FFT< T_Scalar, T_Impl >::inv ( std::vector< Output_ > &  dst,
const std::vector< Complex > &  src,
Index  nfft = -1 
)
inline

Definition at line 368 of file FFT.

369  {
370  if (nfft<1)
371  nfft = ( NumTraits<Output_>::IsComplex == 0 && HasFlag(HalfSpectrum) ) ? 2*(src.size()-1) : src.size();
372  dst.resize( nfft );
373  inv( &dst[0],&src[0],nfft);
374  }

◆ ReflectSpectrum()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::ReflectSpectrum ( Complex freq,
Index  nfft 
)
inlineprivate

Definition at line 409 of file FFT.

410  {
411  // create the implicit right-half spectrum (conjugate-mirror of the left-half)
412  Index nhbins=(nfft>>1)+1;
413  for (Index k=nhbins;k < nfft; ++k )
414  freq[k] = conj(freq[nfft-k]);
415  }
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)

◆ scale()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
template<typename T_Data >
void Eigen::FFT< T_Scalar, T_Impl >::scale ( T_Data *  x,
Scalar  s,
Index  nx 
)
inlineprivate

Definition at line 394 of file FFT.

395  {
396 #if 1
397  for (int k=0;k<nx;++k)
398  *x++ *= s;
399 #else
400  if ( ((ptrdiff_t)x) & 15 )
402  else
404  //Matrix<T_Data, Dynamic, Dynamic>::Map(x,nx) * s;
405 #endif
406  }

◆ SetFlag()

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
void Eigen::FFT< T_Scalar, T_Impl >::SetFlag ( Flag  f)
inline

Definition at line 199 of file FFT.

199 { m_flag |= (int)f;}

Member Data Documentation

◆ Default

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
constexpr Flag Eigen::FFT< T_Scalar, T_Impl >::Default
staticconstexpr

Definition at line 185 of file FFT.

◆ HalfSpectrum

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
constexpr Flag Eigen::FFT< T_Scalar, T_Impl >::HalfSpectrum
staticconstexpr

Definition at line 187 of file FFT.

◆ m_flag

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
int Eigen::FFT< T_Scalar, T_Impl >::m_flag
private

Definition at line 418 of file FFT.

◆ m_impl

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
impl_type Eigen::FFT< T_Scalar, T_Impl >::m_impl
private

Definition at line 417 of file FFT.

◆ Speedy

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
constexpr Flag Eigen::FFT< T_Scalar, T_Impl >::Speedy
staticconstexpr

Definition at line 188 of file FFT.

◆ Unscaled

template<typename T_Scalar , typename T_Impl = default_fft_impl<T_Scalar>>
constexpr Flag Eigen::FFT< T_Scalar, T_Impl >::Unscaled
staticconstexpr

Definition at line 186 of file FFT.


The documentation for this class was generated from the following file: