diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT index caaf79714..6c8cf7fdd 100644 --- a/unsupported/Eigen/FFT +++ b/unsupported/Eigen/FFT @@ -185,7 +185,13 @@ class FFT dst->derived().resize( (src.size()>>1)+1); else dst->derived().resize(src.size()); - fwd( &(*dst)[0],&src[0],src.size() ); + + if (src.stride() != 1) { + Matrix tmp = src; + fwd( &(*dst)[0],&tmp[0],src.size() ); + }else{ + fwd( &(*dst)[0],&src[0],src.size() ); + } } inline @@ -219,7 +225,12 @@ class FFT int nfft = src.size(); int nout = HasFlag(HalfSpectrum) ? ((nfft>>1)+1) : nfft; dst->derived().resize( nout ); - inv( &(*dst)[0],&src[0], nfft); + if (src.stride() != 1) { + Matrix tmp = src; + inv( &(*dst)[0],&tmp[0], nfft); + }else{ + inv( &(*dst)[0],&src[0], nfft); + } } template diff --git a/unsupported/test/FFTW.cpp b/unsupported/test/FFTW.cpp index df38efe64..47ef5de97 100644 --- a/unsupported/test/FFTW.cpp +++ b/unsupported/test/FFTW.cpp @@ -123,43 +123,27 @@ void test_complex(int nfft) template void test_complex2d() { - typedef typename Eigen::FFT::Complex Complex; FFT fft; + Eigen::Matrix src,src2,dst,dst2; - Eigen::Matrix src; - Eigen::Matrix dst; - Eigen::Matrix src2; - Eigen::Matrix dst2; - - //src = Eigen::Matrix::Random(); - src = Eigen::Matrix::Identity(); + src = Eigen::Matrix::Random(); + //src = Eigen::Matrix::Identity(); for (int k=0;k tmpIn = src.col(k); Eigen::Matrix tmpOut; - fft.fwd( &tmpOut,tmpIn ); + fft.fwd( &tmpOut,src.col(k) ); dst2.col(k) = tmpOut; } - //cout << "dst2: " << dst2 << "\n\n"; for (int k=0;k tmpIn = dst2.row(k); Eigen::Matrix tmpOut; - fft.fwd( &tmpOut, tmpIn); + fft.fwd( &tmpOut, dst2.row(k) ); dst2.row(k) = tmpOut; } -/* -*/ fft.fwd2(dst.data(),src.data(),nrows,ncols); fft.inv2(src2.data(),dst.data(),nrows,ncols); - /* - cout << "src: " << src << "\n\n"; - cout << "dst: " << dst << "\n\n"; - cout << "src2: " << src2 << "\n\n"; - cout << "dst2: " << dst2 << "\n\n"; - */ VERIFY( (src-src2).norm() < test_precision() ); VERIFY( (dst-dst2).norm() < test_precision() ); }