From cd7912313dc2477283de767029462d7d0e6ee8ab Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Fri, 22 Jan 2010 00:35:03 -0500 Subject: changed FFT function vector and Matrix args to pointer as Benoit suggested implemented 2D Complex FFT for FFTW impl --- unsupported/Eigen/FFT | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'unsupported/Eigen/FFT') diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT index e0841a4e3..caaf79714 100644 --- a/unsupported/Eigen/FFT +++ b/unsupported/Eigen/FFT @@ -152,20 +152,26 @@ class FFT m_impl.fwd(dst,src,nfft); } + inline + void fwd2(Complex * dst, const Complex * src, int nrows,int ncols) + { + m_impl.fwd2(dst,src,nrows,ncols); + } + template inline - void fwd( std::vector & dst, const std::vector<_Input> & src) + void fwd( std::vector * dst, const std::vector<_Input> & src) { if ( NumTraits<_Input>::IsComplex == 0 && HasFlag(HalfSpectrum) ) - dst.resize( (src.size()>>1)+1); + dst->resize( (src.size()>>1)+1); else - dst.resize(src.size()); - fwd(&dst[0],&src[0],static_cast(src.size())); + dst->resize(src.size()); + fwd(&(*dst)[0],&src[0],static_cast(src.size())); } template inline - void fwd( MatrixBase & dst, const MatrixBase & src) + void fwd( MatrixBase * dst, const MatrixBase & src) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived) @@ -176,10 +182,10 @@ class FFT THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) if ( NumTraits< typename InputDerived::Scalar >::IsComplex == 0 && HasFlag(HalfSpectrum) ) - dst.derived().resize( (src.size()>>1)+1); + dst->derived().resize( (src.size()>>1)+1); else - dst.derived().resize(src.size()); - fwd( &dst[0],&src[0],src.size() ); + dst->derived().resize(src.size()); + fwd( &(*dst)[0],&src[0],src.size() ); } inline @@ -200,7 +206,7 @@ class FFT template inline - void inv( MatrixBase & dst, const MatrixBase & src) + void inv( MatrixBase * dst, const MatrixBase & src) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(OutputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived) @@ -212,19 +218,28 @@ class FFT int nfft = src.size(); int nout = HasFlag(HalfSpectrum) ? ((nfft>>1)+1) : nfft; - dst.derived().resize( nout ); - inv( &dst[0],&src[0], nfft); + dst->derived().resize( nout ); + inv( &(*dst)[0],&src[0], nfft); } template inline - void inv( std::vector<_Output> & dst, const std::vector & src) + void inv( std::vector<_Output> * dst, const std::vector & src) { if ( NumTraits<_Output>::IsComplex == 0 && HasFlag(HalfSpectrum) ) - dst.resize( 2*(src.size()-1) ); + dst->resize( 2*(src.size()-1) ); else - dst.resize( src.size() ); - inv( &dst[0],&src[0],static_cast(dst.size()) ); + dst->resize( src.size() ); + inv( &(*dst)[0],&src[0],static_cast(dst->size()) ); + } + + + inline + void inv2(Complex * dst, const Complex * src, int nrows,int ncols) + { + m_impl.inv2(dst,src,nrows,ncols); + if ( HasFlag( Unscaled ) == false) + scale(dst,1./(nrows*ncols),nrows*ncols); } // TODO: multi-dimensional FFTs -- cgit v1.2.3