added inlines to a bunch of functions

This commit is contained in:
Mark Borgerding 2009-10-31 00:13:22 -04:00
parent 4c3345364e
commit ec70f8006b
3 changed files with 366 additions and 346 deletions

View File

@ -85,6 +85,7 @@ class FFT
inline inline
void ClearFlag(Flag f) { m_flag &= (~(int)f);} void ClearFlag(Flag f) { m_flag &= (~(int)f);}
inline
void fwd( Complex * dst, const Scalar * src, int nfft) void fwd( Complex * dst, const Scalar * src, int nfft)
{ {
m_impl.fwd(dst,src,nfft); m_impl.fwd(dst,src,nfft);
@ -92,12 +93,14 @@ class FFT
ReflectSpectrum(dst,nfft); ReflectSpectrum(dst,nfft);
} }
inline
void fwd( Complex * dst, const Complex * src, int nfft) void fwd( Complex * dst, const Complex * src, int nfft)
{ {
m_impl.fwd(dst,src,nfft); m_impl.fwd(dst,src,nfft);
} }
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) )
@ -108,6 +111,7 @@ class FFT
} }
template<typename InputDerived, typename ComplexDerived> template<typename InputDerived, typename ComplexDerived>
inline
void fwd( MatrixBase<ComplexDerived> & dst, const MatrixBase<InputDerived> & src) void fwd( MatrixBase<ComplexDerived> & dst, const MatrixBase<InputDerived> & src)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputDerived)
@ -125,6 +129,7 @@ class FFT
fwd( &dst[0],&src[0],src.size() ); fwd( &dst[0],&src[0],src.size() );
} }
inline
void inv( Complex * dst, const Complex * src, int nfft) void inv( Complex * dst, const Complex * src, int nfft)
{ {
m_impl.inv( dst,src,nfft ); m_impl.inv( dst,src,nfft );
@ -132,6 +137,7 @@ class FFT
scale(dst,1./nfft,nfft); scale(dst,1./nfft,nfft);
} }
inline
void inv( Scalar * dst, const Complex * src, int nfft) void inv( Scalar * dst, const Complex * src, int nfft)
{ {
m_impl.inv( dst,src,nfft ); m_impl.inv( dst,src,nfft );
@ -140,6 +146,7 @@ class FFT
} }
template<typename OutputDerived, typename ComplexDerived> template<typename OutputDerived, typename ComplexDerived>
inline
void inv( MatrixBase<OutputDerived> & dst, const MatrixBase<ComplexDerived> & src) void inv( MatrixBase<OutputDerived> & dst, const MatrixBase<ComplexDerived> & src)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OutputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(OutputDerived)
@ -157,6 +164,7 @@ class FFT
} }
template <typename _Output> template <typename _Output>
inline
void inv( std::vector<_Output> & dst, const std::vector<Complex> & src) void inv( std::vector<_Output> & dst, const std::vector<Complex> & src)
{ {
if ( NumTraits<_Output>::IsComplex == 0 && HasFlag(HalfSpectrum) ) if ( NumTraits<_Output>::IsComplex == 0 && HasFlag(HalfSpectrum) )
@ -171,18 +179,22 @@ class FFT
// TODO: handle Eigen MatrixBase // TODO: handle Eigen MatrixBase
// ---> i added fwd and inv specializations above + unit test, is this enough? (bjacob) // ---> i added fwd and inv specializations above + unit test, is this enough? (bjacob)
inline
impl_type & impl() {return m_impl;} impl_type & impl() {return m_impl;}
private: private:
template <typename _It,typename _Val> template <typename _It,typename _Val>
inline
void scale(_It x,_Val s,int nx) void scale(_It x,_Val s,int nx)
{ {
for (int k=0;k<nx;++k) for (int k=0;k<nx;++k)
*x++ *= s; *x++ *= s;
} }
inline
void ReflectSpectrum(Complex * freq,int nfft) void ReflectSpectrum(Complex * freq,int nfft)
{ {
// create the implicit right-half spectrum (conjugate-mirror of the left-half)
int nhbins=(nfft>>1)+1; int nhbins=(nfft>>1)+1;
for (int k=nhbins;k < nfft; ++k ) for (int k=nhbins;k < nfft; ++k )
freq[k] = conj(freq[nfft-k]); freq[k] = conj(freq[nfft-k]);

View File

@ -166,6 +166,7 @@
m_plans.clear(); m_plans.clear();
} }
// complex-to-complex forward FFT
inline inline
void fwd( Complex * dst,const Complex *src,int nfft) void fwd( Complex * dst,const Complex *src,int nfft)
{ {
@ -208,3 +209,5 @@
return m_plans[key]; return m_plans[key];
} }
}; };
/* vim: set filetype=cpp et sw=2 ts=2 ai: */

View File

@ -27,9 +27,9 @@
// This FFT implementation was derived from kissfft http:sourceforge.net/projects/kissfft // This FFT implementation was derived from kissfft http:sourceforge.net/projects/kissfft
// Copyright 2003-2009 Mark Borgerding // Copyright 2003-2009 Mark Borgerding
template <typename _Scalar> template <typename _Scalar>
struct ei_kiss_cpx_fft struct ei_kiss_cpx_fft
{ {
typedef _Scalar Scalar; typedef _Scalar Scalar;
typedef std::complex<Scalar> Complex; typedef std::complex<Scalar> Complex;
std::vector<Complex> m_twiddles; std::vector<Complex> m_twiddles;
@ -38,6 +38,7 @@
std::vector<Complex> m_scratchBuf; std::vector<Complex> m_scratchBuf;
bool m_inverse; bool m_inverse;
inline
void make_twiddles(int nfft,bool inverse) void make_twiddles(int nfft,bool inverse)
{ {
m_inverse = inverse; m_inverse = inverse;
@ -71,6 +72,7 @@
} }
template <typename _Src> template <typename _Src>
inline
void work( int stage,Complex * xout, const _Src * xin, size_t fstride,size_t in_stride) void work( int stage,Complex * xout, const _Src * xin, size_t fstride,size_t in_stride)
{ {
int p = m_stageRadix[stage]; int p = m_stageRadix[stage];
@ -269,11 +271,11 @@
} }
} }
} }
}; };
template <typename _Scalar> template <typename _Scalar>
struct ei_kissfft_impl struct ei_kissfft_impl
{ {
typedef _Scalar Scalar; typedef _Scalar Scalar;
typedef std::complex<Scalar> Complex; typedef std::complex<Scalar> Complex;
@ -402,4 +404,7 @@
} }
return &twidref[0]; return &twidref[0];
} }
}; };
/* vim: set filetype=cpp et sw=2 ts=2 ai: */