2009-05-19 12:21:04 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-28 09:32:42 +08:00
|
|
|
// for linear algebra.
|
2009-05-19 12:21:04 +08:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2009-05-26 08:35:24 +08:00
|
|
|
// 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
|
2009-05-19 12:21:04 +08:00
|
|
|
|
2009-05-28 09:32:42 +08:00
|
|
|
// FFTW: faster, GPL -- incompatible with Eigen in LGPL form, bigger code size
|
2009-05-31 05:55:47 +08:00
|
|
|
#ifdef FFTW_ESTIMATE // definition of FFTW_ESTIMATE indicates the caller has included fftw3.h, we can use FFTW routines
|
|
|
|
#include "src/FFT/ei_fftw_impl.h"
|
2009-06-01 03:44:57 +08:00
|
|
|
#undef DEFAULT_FFT_IMPL
|
|
|
|
#define DEFAULT_FFT_IMPL ei_fftw_impl
|
2009-05-19 12:21:04 +08:00
|
|
|
#endif
|
|
|
|
|
2009-05-28 09:32:42 +08:00
|
|
|
// intel Math Kernel Library: fastest, commerical -- incompatible with Eigen in GPL form
|
2009-05-19 12:21:04 +08:00
|
|
|
#ifdef _MKL_DFTI_H_ // mkl_dfti.h has been included, we can use MKL FFT routines
|
|
|
|
// TODO
|
2009-05-26 08:35:24 +08:00
|
|
|
// #include "src/FFT/ei_imkl_impl.h"
|
|
|
|
// #define DEFAULT_FFT_IMPL ei_imkl_impl
|
2009-05-19 12:21:04 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Eigen {
|
|
|
|
|
|
|
|
template <typename _Scalar,
|
2009-05-26 08:35:24 +08:00
|
|
|
typename _Traits=DEFAULT_FFT_IMPL<_Scalar>
|
2009-05-19 12:21:04 +08:00
|
|
|
>
|
|
|
|
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) { }
|
|
|
|
|
2009-05-23 10:37:59 +08:00
|
|
|
template <typename _Input>
|
|
|
|
void fwd( Complex * dst, const _Input * src, int nfft)
|
2009-05-19 12:21:04 +08:00
|
|
|
{
|
2009-05-23 22:09:48 +08:00
|
|
|
m_traits.fwd(dst,src,nfft);
|
2009-05-19 12:21:04 +08:00
|
|
|
}
|
|
|
|
|
2009-05-23 10:37:59 +08:00
|
|
|
template <typename _Input>
|
|
|
|
void fwd( std::vector<Complex> & dst, const std::vector<_Input> & src)
|
2009-05-19 12:21:04 +08:00
|
|
|
{
|
2009-05-23 10:37:59 +08:00
|
|
|
dst.resize( src.size() );
|
|
|
|
fwd( &dst[0],&src[0],src.size() );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename _Output>
|
|
|
|
void inv( _Output * dst, const Complex * src, int nfft)
|
|
|
|
{
|
2009-05-23 22:09:48 +08:00
|
|
|
m_traits.inv( dst,src,nfft );
|
2009-05-23 10:37:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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() );
|
2009-05-19 12:21:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: multi-dimensional FFTs
|
|
|
|
// TODO: handle Eigen MatrixBase
|
|
|
|
|
|
|
|
traits_type & traits() {return m_traits;}
|
|
|
|
private:
|
|
|
|
traits_type m_traits;
|
|
|
|
};
|
2009-05-26 08:35:24 +08:00
|
|
|
#undef DEFAULT_FFT_IMPL
|
2009-05-19 12:21:04 +08:00
|
|
|
}
|
|
|
|
#endif
|