diff options
author | Mark Borgerding <mark@borgerding.net> | 2009-05-25 20:35:24 -0400 |
---|---|---|
committer | Mark Borgerding <mark@borgerding.net> | 2009-05-25 20:35:24 -0400 |
commit | 210092d16c57ec2fd2f8f515151de284e8a737e3 (patch) | |
tree | 1037d09248290702b3bb45dd37baece58b50cf7f /unsupported/Eigen/FFT | |
parent | 326ea773908c2d7e46101085af8f72d20b3f8cbc (diff) |
changed name from simple_fft_traits to ei_kissfft_impl
Diffstat (limited to 'unsupported/Eigen/FFT')
-rw-r--r-- | unsupported/Eigen/FFT | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT new file mode 100644 index 000000000..3d852f5a2 --- /dev/null +++ b/unsupported/Eigen/FFT @@ -0,0 +1,95 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2009 Mark Borgerding mark a borgerding net +// +// Eigen is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// Alternatively, you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License and a copy of the GNU General Public License along with +// Eigen. If not, see <http://www.gnu.org/licenses/>. + +#ifndef EIGEN_FFT_H +#define EIGEN_FFT_H + +// ei_kissfft_impl: small, free, reasonably efficient default, derived from kissfft +#include "src/FFT/ei_kissfft_impl.h" +#define DEFAULT_FFT_IMPL ei_kissfft_impl + +// FFTW: faster, GPL-not LGPL, bigger code size +#ifdef FFTW_PATIENT // definition of FFTW_PATIENT indicates the caller has included fftw3.h, we can use FFTW routines +// TODO +// #include "src/FFT/ei_fftw_impl.h" +// #define DEFAULT_FFT_IMPL ei_fftw_impl +#endif + +// intel Math Kernel Library: fastest, commerical +#ifdef _MKL_DFTI_H_ // mkl_dfti.h has been included, we can use MKL FFT routines +// TODO +// #include "src/FFT/ei_imkl_impl.h" +// #define DEFAULT_FFT_IMPL ei_imkl_impl +#endif + +namespace Eigen { + +template <typename _Scalar, + typename _Traits=DEFAULT_FFT_IMPL<_Scalar> + > +class FFT +{ + public: + typedef _Traits traits_type; + typedef typename traits_type::Scalar Scalar; + typedef typename traits_type::Complex Complex; + + FFT(const traits_type & traits=traits_type() ) :m_traits(traits) { } + + template <typename _Input> + void fwd( Complex * dst, const _Input * src, int nfft) + { + m_traits.fwd(dst,src,nfft); + } + + template <typename _Input> + void fwd( std::vector<Complex> & dst, const std::vector<_Input> & src) + { + dst.resize( src.size() ); + fwd( &dst[0],&src[0],src.size() ); + } + + template <typename _Output> + void inv( _Output * dst, const Complex * src, int nfft) + { + m_traits.inv( dst,src,nfft ); + } + + template <typename _Output> + void inv( std::vector<_Output> & dst, const std::vector<Complex> & src) + { + dst.resize( src.size() ); + inv( &dst[0],&src[0],src.size() ); + } + + // TODO: multi-dimensional FFTs + // TODO: handle Eigen MatrixBase + + traits_type & traits() {return m_traits;} + private: + traits_type m_traits; +}; +#undef DEFAULT_FFT_IMPL +} +#endif |