added non-optimized real forward fft (no inverse yet)

This commit is contained in:
Mark Borgerding
2009-05-22 22:37:59 -04:00
parent 68cad98bc9
commit 8b4afe3deb
3 changed files with 106 additions and 44 deletions

View File

@@ -57,21 +57,36 @@ class FFT
FFT(const traits_type & traits=traits_type() ) :m_traits(traits) { }
void fwd( Complex * dst, const Complex * src, int nfft)
template <typename _Input>
void fwd( Complex * dst, const _Input * src, int nfft)
{
m_traits.prepare(nfft,false,dst,src);
m_traits.exec(dst,src);
m_traits.postprocess(dst);
}
void inv( Complex * dst, const Complex * src, int nfft)
template <typename _Input>
void fwd( std::vector<Complex> & dst, const std::vector<_Input> & src)
{
m_traits.prepare(nfft,true,dst,src);
m_traits.exec(dst,src);
m_traits.postprocess(dst);
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.prepare(nfft,true,dst,src);
m_traits.exec(dst,src);
m_traits.postprocess(dst);
}
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: fwd,inv for Scalar
// TODO: multi-dimensional FFTs
// TODO: handle Eigen MatrixBase

View File

@@ -34,7 +34,8 @@ namespace Eigen {
typedef std::complex<Scalar> Complex;
simple_fft_traits() : m_nfft(0) {}
void prepare(int nfft,bool inverse,Complex * dst,const Complex *src)
template <typename _Src>
void prepare(int nfft,bool inverse,Complex * dst,const _Src *src)
{
if (m_nfft == nfft) {
// reuse the twiddles, conjugate if necessary
@@ -73,7 +74,8 @@ namespace Eigen {
}while(n>1);
}
void exec(Complex * dst, const Complex * src)
template <typename _Src>
void exec(Complex * dst, const _Src * src)
{
work(0, dst, src, 1,1);
}
@@ -89,7 +91,9 @@ namespace Eigen {
private:
void work( int stage,Complex * Fout, const Complex * f, size_t fstride,size_t in_stride)
template <typename _Src>
void work( int stage,Complex * Fout, const _Src * f, size_t fstride,size_t in_stride)
{
int p = m_stageRadix[stage];
int m = m_stageRemainder[stage];