ADD: added other eigen lib
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef EIGEN_FFT_H
|
||||
#define EIGEN_FFT_H
|
||||
#ifndef EIGEN_FFT_MODULE_H
|
||||
#define EIGEN_FFT_MODULE_H
|
||||
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
@@ -29,10 +29,19 @@
|
||||
* The default implementation is based on kissfft. It is a small, free, and
|
||||
* reasonably efficient default.
|
||||
*
|
||||
* There are currently two implementation backend:
|
||||
* There are currently four implementation backend:
|
||||
*
|
||||
* - kissfft(https://github.com/mborgerding/kissfft) : Simple and not so fast, BSD-3-Clause.
|
||||
* It is a mixed-radix Fast Fourier Transform based up on the principle, "Keep It Simple, Stupid."
|
||||
* Notice that:kissfft fails to handle "atypically-sized" inputs(i.e., sizes with large factors),a workaround is using fftw or pocketfft.
|
||||
* - fftw (http://www.fftw.org) : faster, GPL -- incompatible with Eigen in LGPL form, bigger code size.
|
||||
* - MKL (http://en.wikipedia.org/wiki/Math_Kernel_Library) : fastest, commercial -- may be incompatible with Eigen in GPL form.
|
||||
* - MKL (https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html) : fastest, free -- may be incompatible with Eigen in GPL form.
|
||||
* - pocketfft (https://gitlab.mpcdf.mpg.de/mtr/pocketfft) : faster than kissfft, BSD 3-clause.
|
||||
* It is a heavily modified implementation of FFTPack, with the following advantages:
|
||||
* 1.strictly C++11 compliant
|
||||
* 2.more accurate twiddle factor computation
|
||||
* 3.very fast plan generation
|
||||
* 4.worst case complexity for transform sizes with large prime factors is N*log(N), because Bluestein's algorithm is used for these cases
|
||||
*
|
||||
* \section FFTDesign Design
|
||||
*
|
||||
@@ -79,15 +88,21 @@
|
||||
template <typename T> struct default_fft_impl : public internal::fftw_impl<T> {};
|
||||
}
|
||||
#elif defined EIGEN_MKL_DEFAULT
|
||||
// TODO
|
||||
// intel Math Kernel Library: fastest, commercial -- may be incompatible with Eigen in GPL form
|
||||
// intel Math Kernel Library: fastest, free -- may be incompatible with Eigen in GPL form
|
||||
# include "src/FFT/ei_imklfft_impl.h"
|
||||
namespace Eigen {
|
||||
template <typename T> struct default_fft_impl : public internal::imklfft_impl {};
|
||||
template <typename T> struct default_fft_impl : public internal::imklfft::imklfft_impl<T> {};
|
||||
}
|
||||
#else
|
||||
#elif defined EIGEN_POCKETFFT_DEFAULT
|
||||
// internal::pocketfft_impl: a heavily modified implementation of FFTPack, with many advantages.
|
||||
# include<pocketfft_hdronly.h>
|
||||
# include"src/FFT/ei_pocketfft_impl.h"
|
||||
namespace Eigen {
|
||||
template <typename T>
|
||||
struct default_fft_impl : public internal::pocketfft_impl<T> {};
|
||||
}
|
||||
#else
|
||||
// internal::kissfft_impl: small, free, reasonably efficient default, derived from kissfft
|
||||
//
|
||||
# include "src/FFT/ei_kissfft_impl.h"
|
||||
namespace Eigen {
|
||||
template <typename T>
|
||||
@@ -195,19 +210,19 @@ class FFT
|
||||
m_impl.fwd(dst,src,static_cast<int>(nfft));
|
||||
}
|
||||
|
||||
/*
|
||||
#if defined EIGEN_FFTW_DEFAULT || defined EIGEN_POCKETFFT_DEFAULT || defined EIGEN_MKL_DEFAULT
|
||||
inline
|
||||
void fwd2(Complex * dst, const Complex * src, int n0,int n1)
|
||||
{
|
||||
m_impl.fwd2(dst,src,n0,n1);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
template <typename _Input>
|
||||
template <typename Input_>
|
||||
inline
|
||||
void fwd( std::vector<Complex> & dst, const std::vector<_Input> & src)
|
||||
void fwd( std::vector<Complex> & dst, const std::vector<Input_> & src)
|
||||
{
|
||||
if ( NumTraits<_Input>::IsComplex == 0 && HasFlag(HalfSpectrum) )
|
||||
if ( NumTraits<Input_>::IsComplex == 0 && HasFlag(HalfSpectrum) )
|
||||
dst.resize( (src.size()>>1)+1); // half the bins + Nyquist bin
|
||||
else
|
||||
dst.resize(src.size());
|
||||
@@ -343,19 +358,18 @@ class FFT
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _Output>
|
||||
template <typename Output_>
|
||||
inline
|
||||
void inv( std::vector<_Output> & dst, const std::vector<Complex> & src,Index nfft=-1)
|
||||
void inv( std::vector<Output_> & dst, const std::vector<Complex> & src,Index nfft=-1)
|
||||
{
|
||||
if (nfft<1)
|
||||
nfft = ( NumTraits<_Output>::IsComplex == 0 && HasFlag(HalfSpectrum) ) ? 2*(src.size()-1) : src.size();
|
||||
nfft = ( NumTraits<Output_>::IsComplex == 0 && HasFlag(HalfSpectrum) ) ? 2*(src.size()-1) : src.size();
|
||||
dst.resize( nfft );
|
||||
inv( &dst[0],&src[0],nfft);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// TODO: multi-dimensional FFTs
|
||||
#if defined EIGEN_FFTW_DEFAULT || defined EIGEN_POCKETFFT_DEFAULT || defined EIGEN_MKL_DEFAULT
|
||||
inline
|
||||
void inv2(Complex * dst, const Complex * src, int n0,int n1)
|
||||
{
|
||||
@@ -363,7 +377,8 @@ class FFT
|
||||
if ( HasFlag( Unscaled ) == false)
|
||||
scale(dst,1./(n0*n1),n0*n1);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
inline
|
||||
impl_type & impl() {return m_impl;}
|
||||
|
||||
Reference in New Issue
Block a user