/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLMath/src/ICLMath/FFTUtils.cpp ** ** Module : ICLMath ** ** Authors: Christian Groszewski, Christof Elbrechter ** ** ** ** ** ** GNU LESSER GENERAL PUBLIC LICENSE ** ** This file may be used under the terms of the GNU Lesser General ** ** Public License version 3.0 as published by the ** ** ** ** Free Software Foundation and appearing in the file LICENSE.LGPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the license requirements will ** ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** ********************************************************************/ #include #include #ifdef ICL_SYSTEM_WINDOWS #ifdef min #undef min #undef max #endif #endif //#define FFT_DEBUG(X) std::cout << X << std::endl; #define FFT_DEBUG(X) using namespace icl::utils; namespace icl{ namespace math{ namespace fft{ typedef std::complex icl32c; typedef std::complex icl64c; template struct CreateComplex{ static inline std::complex create_complex(const T1 &x){ return std::complex(x); } }; #define ICL_INSTANTIATE_DEPTH(D) \ template \ struct CreateComplex{ \ static inline std::complex create_complex(const icl##D &x){ \ return std::complex((T2)x,0.0); \ } \ }; \ template \ struct CreateComplex,T2>{ \ static inline std::complex create_complex(const std::complex &x){ \ return std::complex((T2)x.real(),(T2)x.imag()); \ } \ }; ICL_INSTANTIATE_ALL_DEPTHS; ICL_INSTANTIATE_DEPTH(32u); ICL_INSTANTIATE_DEPTH(16u); #undef ICL_INSTANTIATE_DEPTH template DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst) throw (InvalidMatrixDimensionException){ if(src.cols() != dst.cols() || src.rows() != dst.rows()) throw InvalidMatrixDimensionException("number of columns(rows) of sourcematrix must be equal to number of colums(rows) of destinationmatrix"); unsigned int cols = src.cols(); unsigned int rows = src.rows(); unsigned int cols2 = cols/2; unsigned int rows2 = rows/2; if(cols >1 && rows > 1){ for(unsigned int y=0;y& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& fftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix >& fftshift(DynMatrix > &src, DynMatrix > &dst); template DynMatrix& ifftshift(DynMatrix &src, DynMatrix &dst) throw (InvalidMatrixDimensionException){ if(src.cols() != dst.cols() || src.rows() != dst.rows()) throw InvalidMatrixDimensionException("number of columns(rows) of sourcematrix must " "be equal to number of colums(rows) " "of destinationmatrix"); unsigned int cols = src.cols(); unsigned int rows = src.rows(); unsigned int cols2 = cols/2; unsigned int rows2 = rows/2; if(cols >1 && rows > 1){ for(unsigned int y=0;y0;--x){ std::swap(dst.operator ()(x,y),dst.operator ()(x-1,y)); } } } else if(cols%2==0 && rows%2==1){ for(unsigned int x=0;x0;--y){ std::swap(dst.operator ()(x,y),dst.operator ()(x,y-1)); } } } else { for(unsigned int y=0;y0;--x){ std::swap(dst.operator ()(x,y),dst.operator ()(x-1,y)); } } for(unsigned int x=0;x0;--y){ std::swap(dst.operator ()(x,y),dst.operator ()(x,y-1)); } } } } else { int dim = cols*rows; int tmp = dim/2; for(int i=0;i& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& ifftshift(DynMatrix &src,DynMatrix &dst); template ICLMath_API DynMatrix >& ifftshift(DynMatrix > &src, DynMatrix > &dst); int priorPowerOf2(int n){ int p = 1; while(p DynMatrix& logpowerspectrum(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } std::complex temp = (T)0.0; const std::complex* srcdata = src.data(); T* dstdata = dst.data(); T epsilon = std::numeric_limits::min(); // 1.17549e-38 in order to avoid log(0) for(unsigned int i=0;i& logpowerspectrum(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& logpowerspectrum(const DynMatrix > &src, DynMatrix &dst); template DynMatrix& powerspectrum(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } const std::complex* srcdata = src.data(); std::complex temp = (T)0.0; T* dstdata = dst.data(); for(unsigned int i=0;i& powerspectrum(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& powerspectrum(const DynMatrix > &src, DynMatrix &dst); template DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst){ unsigned int newCols = nextPowerOf2(src.cols()); unsigned int newRows = nextPowerOf2(src.rows()); if(dst.cols() != newCols || dst.rows() != newRows){ dst.setBounds(newCols,newRows); } unsigned int nc = src.cols(); unsigned int nr = src.rows(); for(unsigned int i=0;i& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2( const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& continueMatrixToPowerOf2(const DynMatrix &, DynMatrix &dst); template ICLMath_API DynMatrix >& continueMatrixToPowerOf2(const DynMatrix > &src, DynMatrix > &dst); template DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst){ unsigned int srcCols = src.cols(); unsigned int srcRows = src.rows(); unsigned int newCols = nextPowerOf2(srcCols); unsigned int newRows = nextPowerOf2(srcRows); if(newCols==srcCols && newRows==srcRows){ dst = src; return dst; } if(dst.cols() != newCols || dst.rows() != newRows){ dst.setBounds(newCols,newRows); } unsigned int nc = (newCols-srcCols)/2; unsigned int nr = (newRows-srcRows)/2; for(unsigned int i=0;i &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter( const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &mirrorOnCenter(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix > &mirrorOnCenter( const DynMatrix > &src, DynMatrix > &dst); template DynMatrix & makeborder(const DynMatrix &src, DynMatrix &dst, T borderFill){ unsigned int srcCols = src.cols(); unsigned int srcRows = src.rows(); unsigned int newCols = nextPowerOf2(srcCols); unsigned int newRows = nextPowerOf2(srcRows); if(dst.cols() != newCols || dst.rows() != newRows){ dst.setBounds(newCols,newRows); } unsigned int nc = (newCols-srcCols)/2; unsigned int nr = (newRows-srcRows)/2; std::fill(dst.begin(),dst.end(),borderFill); for(unsigned int i=0;i& makeborder(const DynMatrix &src, DynMatrix &dst, icl8u borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst, icl16u borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst, icl32u borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst, icl16s borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst, icl32s borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst,icl32f borderFill); template ICLMath_API DynMatrix& makeborder( const DynMatrix &src, DynMatrix &dst,icl32c borderFill); template ICLMath_API DynMatrix& makeborder(const DynMatrix &src, DynMatrix &dst,icl64f borderFill); template ICLMath_API DynMatrix >& makeborder( const DynMatrix > &src, DynMatrix > &dst,std::complex borderFill); template DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } const std::complex *srcdata = src.data(); T2 *dstdata = dst.data(); for(unsigned int i=0;i &imagpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix &imagpart(const DynMatrix > &src, DynMatrix &dst); template DynMatrix &realpart(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } const std::complex *srcdata = src.data(); T2 *dstdata = dst.data(); for(unsigned int i=0;i& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& realpart(const DynMatrix > &src, DynMatrix &dst); template void split_complex(const DynMatrix > &src, DynMatrix &real,DynMatrix &img){ if(real.cols() != src.cols() || real.rows() != src.rows()){ real.setBounds(src.cols(),src.rows()); } if(img.cols() != src.cols() || img.rows() != src.rows()){ img.setBounds(src.cols(),src.rows()); } const std::complex *srcdata = src.data(); T *realdata = real.data(); T *imagdata = img.data(); for(unsigned int i=0;i &src,DynMatrix &real, DynMatrix &img); template ICLMath_API void split_complex(const DynMatrix > &src,DynMatrix &real, DynMatrix &img); template DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } const std::complex *srcdata = src.data(); T2 *dstdata = dst.data(); for(unsigned int i=0;i& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& magnitude(const DynMatrix > &src, DynMatrix &dst); template DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst){ if(dst.cols() != src.cols() || dst.rows() != src.rows()){ dst.setBounds(src.cols(),src.rows()); } T1 im = (T1)0; T1 re = (T1)0; const std::complex *srcdata = src.data(); T2 *dstdata = dst.data(); for(unsigned int i=0;i=zero){ dstdata[i] = (T2) atan2(im,re)+FFT_PI; } else if(rezero){ dstdata[i] = (T2) FFT_PI_HALF; } else if(re==zero && im& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template ICLMath_API DynMatrix& phase(const DynMatrix > &src, DynMatrix &dst); template void split_magnitude_phase(const DynMatrix > &src, DynMatrix &magnitude,DynMatrix &phase){ if(magnitude.cols() != src.cols() || magnitude.rows() != src.rows()){ magnitude.setBounds(src.cols(),src.rows()); } if(phase.cols() != src.cols() || phase.rows() != src.rows()){ phase.setBounds(src.cols(),src.rows()); } T im; T re; T zero = (T) 0; const std::complex *srcdata = src.data(); T *magnitudedata = magnitude.data(); T *phasedata = phase.data(); for(unsigned int i=0;i=zero){ phasedata[i] = (T) atan2(im,re)+FFT_PI; } else if(rezero){ phasedata[i] = (T) FFT_PI_HALF; } else if(re==zero && im &src, DynMatrix &magnitude, DynMatrix &phase); template ICLMath_API void split_magnitude_phase(const DynMatrix > &src, DynMatrix &magnitude, DynMatrix &phase); template DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im, DynMatrix > &dst){ if(real.cols() != im.cols() || real.rows() != im.rows()){ throw FFTException("param1 1 and param 2 in icl::fft::joinComplex have not the same size"); } if(dst.cols() != real.cols() || dst.rows() != real.rows()){ dst.setBounds(real.cols(),real.rows()); } const T1 *realdata = real.data(); const T1 *imdata = im.data(); std::complex *dstdata = dst.data(); for(unsigned int i=0;i((T2)realdata[i],(T2)imdata[i]); } return dst; } template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); template ICLMath_API DynMatrix > &joinComplex(const DynMatrix &real, const DynMatrix &im,DynMatrix > &dst); double f = 0.0; template std::complex* fft(unsigned int n, const T1* a){ if(n==1){ std::complex *cpya = new std::complex[1]; cpya[0] = (std::complex)a[0]; return cpya; } else if(n%2==0){ unsigned int halfsize = n/2; T1 *even = new T1[halfsize]; T1 *odd = new T1[halfsize]; //unsigned int i=0; unsigned int j=0; //split array for(unsigned int i=0;i* g = fft(halfsize,even); std::complex* u = fft(halfsize,odd); std::complex* c = new std::complex[n]; double cp = -(FFT_2_PI)/n; std::complex fac(0.0,0.0); for(unsigned int k=0;k(std::cos(f),std::sin(f)); c[k]=g[k]+fac; c[k+halfsize]=g[k]-fac; } delete[] even; delete[] odd; delete[] g; delete[] u; return c; } else { T2 omega = -FFT_2_PI/n; std::complex *m3 = new std::complex[n]; std::complex x((T2)0.0,(T2)0.0); T2 y = (T2) 0; for(unsigned int p =0;p(0.0,0.0); y=p*omega; for(unsigned int q = 0;q(std::cos(y*q),std::sin(y*q))*((std::complex)a[q])); } m3[p]=x; } return m3; } } template ICLMath_API icl32c* fft(unsigned int n, const icl8u* a); template ICLMath_API icl32c* fft(unsigned int n, const icl16u* a); template ICLMath_API icl32c* fft(unsigned int n, const icl32u* a); template ICLMath_API icl32c* fft(unsigned int n, const icl16s* a); template ICLMath_API icl32c* fft(unsigned int n, const icl32s* a); template ICLMath_API std::complex* fft(unsigned int n, const icl8u* a); template ICLMath_API std::complex* fft(unsigned int n, const icl16u* a); template ICLMath_API std::complex* fft(unsigned int n, const icl32u* a); template ICLMath_API std::complex* fft(unsigned int n, const icl16s* a); template ICLMath_API std::complex* fft(unsigned int n, const icl32s* a); template ICLMath_API icl32c* fft(unsigned int n, const icl32f* a); template ICLMath_API std::complex* fft(unsigned int n, const icl32f* a); template ICLMath_API std::complex* fft(unsigned int n, const icl64f* a); template ICLMath_API icl32c* fft(unsigned int n, const icl64f* a); template ICLMath_API icl32c* fft(unsigned int n, const icl32c* a); template ICLMath_API std::complex* fft(unsigned int n, const icl32c* a); template ICLMath_API std::complex* fft(unsigned int n, const std::complex* a); template ICLMath_API icl32c* fft(unsigned int n, const std::complex* a); #ifdef ICL_HAVE_IPP template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException){ FFT_DEBUG("using ipp fft"); IppiFFTSpec_R_32f *spec = 0; //IppHintAlgorithm hint; IppStatus status = ippiFFTInitAlloc_R_32f(&spec,log2(src.cols()),log2(src.rows()), IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate); //or use ippAlgHintNone if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } int dim = src.cols()*src.rows(); int minBufSize = 0; ippiFFTGetBufSize_R_32f(spec,&minBufSize); int currBufSize = buf.cols()*buf.rows()*sizeof(icl32c)*sizeof(icl32c); Ipp8u *buffer=0; if(currBufSize >= minBufSize){ buffer = reinterpret_cast(buf.data()); }else{ buf.setBounds(src.cols(),src.rows()); buffer = reinterpret_cast(buf.data()); } //needed for type conversation Ipp32f *srcbuf= new Ipp32f[dim]; for(int i=0;i(dst.data()),src.cols()*sizeof(Ipp32fc)); if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } delete[] srcbuf; delete[] dstbuf; return dst; } template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& ipp_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); DynMatrix& ipp_wrapper_function_result_fft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException){ IppiFFTSpec_C_32fc *spec = 0; //IppHintAlgorithm hint; IppStatus status = ippiFFTInitAlloc_C_32fc(&spec,log2(src.cols()),log2(src.rows()), IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate); //or use ippAlgHintNone if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } int minBufSize = 0; ippiFFTGetBufSize_C_32fc(spec,&minBufSize); int currBufSize = buf.cols()*buf.rows()*sizeof(icl32c)*sizeof(icl32c); Ipp8u *buffer=0; if(currBufSize >= minBufSize){ buffer = reinterpret_cast(buf.data()); }else{ buf.setBounds(src.cols(),src.rows()); buffer = reinterpret_cast(buf.data()); } int srcStep = src.cols()*sizeof(Ipp32fc); status = ippiFFTFwd_CToC_32fc_C1R(reinterpret_cast(src.data()), srcStep, reinterpret_cast(dst.data()), srcStep, spec, buffer); if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } status = ippiFFTFree_C_32fc(spec); if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } return dst; } #endif #ifdef ICL_HAVE_MKL #include template void unpack_mkl_fft(T *src,std::complex *dst, unsigned int cols, unsigned int rows){ unsigned int dim = cols*rows; T re = 0.0; T im = 0.0; //first element dst[0]=std::complex(src[0],0); unsigned int j=1; unsigned int offrow = cols*rows/2; //first row for(unsigned int i=1;i(re,im); dst[cols-j] = std::complex(re,-im); ++j; } if(rows%2 ==0){ dst[offrow]=std::complex(src[dim-cols],0); } if(cols%2 ==0){ dst[cols/2]=std::complex(src[cols-1],0); } if(cols%2==0 && rows%2==0){ dst[offrow+cols/2]=std::complex(src[dim-1],0); } j=cols; unsigned int offcol = cols/2; for(unsigned int i=cols;i(re,im); dst[dim-j] = std::complex(re,-im); if(cols%2==0 ){ re =src[i+cols-1]; im = src[i+2*cols-1]; dst[j+offcol] = std::complex(re,im); dst[dim-j+offcol] = std::complex(re,-im); } j+=cols; } unsigned int a = cols/2; if(cols%2==1){ a=cols/2+1; } unsigned int cindex=1; for(unsigned int r=1;r(re,im); dst[dim-j+cols] = std::complex(re,-im); j+=cols; } cindex+=2; } } template void unpack_mkl_fft(float *src, std::complex *dst, unsigned int cols, unsigned int rows); template void unpack_mkl_fft(double *src, std::complex *dst, unsigned int cols, unsigned int rows); template DFTI_CONFIG_VALUE getMKLDftiType(){ return DFTI_DOUBLE; } template<> DFTI_CONFIG_VALUE getMKLDftiType() { return DFTI_SINGLE; } template DynMatrix >& mkl_wrapper_function_result_fft( const DynMatrix &src, DynMatrix > &dst, DynMatrix > &buffer) throw (FFTException){ FFT_DEBUG("using mkl fft2d"); unsigned int dimx = src.cols(); unsigned int dimy = src.rows(); T2 *srcbuf = new T2[dimy*dimx]; for(unsigned int i=0;i(), DFTI_REAL, 2,l); MKL_LONG strides_in[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; MKL_LONG strides_out[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; status = DftiSetValue(my_desc1_handle,DFTI_PLACEMENT, DFTI_NOT_INPLACE); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_PACKED_FORMAT, DFTI_PACK_FORMAT); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_INPUT_STRIDES,strides_in); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_OUTPUT_STRIDES,strides_out); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiCommitDescriptor( my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiCommitDescriptorError"); } T2 *buf = reinterpret_cast(buffer.data()); status = DftiComputeForward( my_desc1_handle, srcbuf, buf); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiComputeForwardError"); } status = DftiFreeDescriptor(&my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftifreeDescriptorError"); } unpack_mkl_fft(buf,dst.data(),dimx,dimy); delete[] srcbuf; return dst; } template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf)throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix >& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf) throw (FFTException); template DynMatrix& mkl_wrapper_function_result_fft(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw (FFTException); template void mkl_wrapper_function_result_fft_complex(DFTI_DESCRIPTOR_HANDLE &my_desc1_handle,T1 *src, std::complex*dst, std::complex *buffer, unsigned int dimx, unsigned int dimy) throw (FFTException){ FFT_DEBUG("using mkl fft2d_complex"); MKL_LONG status; MKL_LONG strides_in[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; MKL_LONG strides_out[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; status = DftiSetValue(my_desc1_handle,DFTI_PLACEMENT, DFTI_NOT_INPLACE); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_INPUT_STRIDES,strides_in); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_OUTPUT_STRIDES,strides_out); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiCommitDescriptor( my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiCommitDescriptorError"); } status = DftiComputeForward( my_desc1_handle, src, reinterpret_cast(dst)); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiComputeForwardError"); } status = DftiFreeDescriptor(&my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiFreeDescriptorError"); } } template void mkl_wrapper_function_result_fft_complex(DFTI_DESCRIPTOR_HANDLE &my_desc1_handle,_MKL_Complex8 *src, icl32c *dst, icl32c *buffer,unsigned int dimx, unsigned int dimy) throw (FFTException); template void mkl_wrapper_function_result_fft_complex(DFTI_DESCRIPTOR_HANDLE &my_desc1_handle,_MKL_Complex16 *src, std::complex *dst, std::complex *buffer,unsigned int dimx, unsigned int dimy) throw (FFTException); DynMatrix& mkl_wrapper_function_result_fft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException){ unsigned int dimx = src.cols(); unsigned int dimy = src.rows(); _MKL_Complex8 *srcbuf = new _MKL_Complex8[dimy*dimx]; for(unsigned int i=0;i(&(src.data()[i]))); } MKL_LONG status, l[2]={(MKL_LONG )dimy,(MKL_LONG )dimx}; DFTI_DESCRIPTOR_HANDLE my_desc1_handle; status = DftiCreateDescriptor( &my_desc1_handle, DFTI_SINGLE, DFTI_COMPLEX, 2,l); (void)status; mkl_wrapper_function_result_fft_complex(my_desc1_handle,srcbuf,dst.data(),buffer.data(),dimx,dimy); delete[] srcbuf; return dst; } DynMatrix >& mkl_wrapper_function_result_fft_icl64fc(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buffer) throw (FFTException){ unsigned int dimx = src.cols(); unsigned int dimy = src.rows(); _MKL_Complex16 *srcbuf = new _MKL_Complex16[dimy*dimx]; for(unsigned int i=0;i(&(src.data()[i]))); } MKL_LONG status, l[2]={(MKL_LONG )dimy,(MKL_LONG )dimx}; DFTI_DESCRIPTOR_HANDLE my_desc1_handle=0; status = DftiCreateDescriptor( &my_desc1_handle, DFTI_DOUBLE, DFTI_COMPLEX, 2,l); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiCreateDescriptorError"); } mkl_wrapper_function_result_fft_complex(my_desc1_handle,srcbuf,dst.data(),buffer.data(),dimx,dimy); delete[] srcbuf; return dst; } #endif template DynMatrix >& fft2D_cpp(const DynMatrix &src,DynMatrix > &dst, DynMatrix > &buf){ FFT_DEBUG("fft2D_cpp"); //check buffer if(buf.isNull() || buf.cols() != src.rows() || buf.rows() != src.cols()){ //always wrong, but in this case really right!!! buf(src.rows(),src.cols()); } unsigned int cols = src.cols(); unsigned int rows = src.rows(); std::complex *temp=0; //already transposed for(unsigned int i=0;i(cols,src.row_begin(i)); for(unsigned int j=0;j,T2 >(rows,buf.row_begin(i)); for(unsigned int j=0;j& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& fft2D_cpp(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& fft2D_cpp(const DynMatrix > &src, DynMatrix &dst, DynMatrix &buf); template DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst, DynMatrix > &buf){ if(isPowerOfTwo(src.cols()) && isPowerOfTwo(src.rows())){ #ifdef ICL_HAVE_IPP buf.setBounds(src.cols(),src.rows()); return ipp_wrapper_function_result_fft(src,dst,buf); #endif } #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); //double template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } //complex template<> ICLMath_API DynMatrix& fft2D(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf){ if(isPowerOfTwo(src.cols()) && isPowerOfTwo(src.rows())){ #ifdef ICL_HAVE_IPP buf.setBounds(src.cols(),src.rows()); return ipp_wrapper_function_result_fft_icl32fc(src,dst,buf); #endif } #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft_icl32fc(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_fft_icl64fc(src,dst,buf); #endif return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& fft2D(const DynMatrix &src,DynMatrix > &dst, DynMatrix > &buf){ return fft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix& fft2D(const DynMatrix > &src,DynMatrix &dst, DynMatrix &buf){ return fft2D_cpp(src,dst,buf); } template std::complex* dft(unsigned int n, T1* src){ std::complex* d = new std::complex[n]; std::complex x = std::complex(0.0,0.0); T2 f= -FFT_2_PI/n; T2 g = 0.0; T2 h = 0.0; std::complex temp(0,0); for(unsigned int i=0;i::create_complex((src[j])) * (std::complex(std::cos(g),std::sin(g)))); } d[i] = x; x = std::complex(0.0,0.0); } return d; } template ICLMath_API icl32c* dft(unsigned int n, icl8u* src); template ICLMath_API std::complex* dft(unsigned int n, icl8u* src); template ICLMath_API icl32c* dft(unsigned int n, icl16u* src); template ICLMath_API std::complex* dft(unsigned int n, icl16u* src); template ICLMath_API icl32c* dft(unsigned int n, icl32u* src); template ICLMath_API std::complex* dft(unsigned int n, icl32u* src); template ICLMath_API icl32c* dft(unsigned int n, icl16s* src); template ICLMath_API std::complex* dft(unsigned int n, icl16s* src); template ICLMath_API icl32c* dft(unsigned int n, icl32s* src); template ICLMath_API std::complex* dft(unsigned int n, icl32s* src); template ICLMath_API icl32c* dft(unsigned int n, icl32f* src); template ICLMath_API std::complex* dft(unsigned int n, icl32f* src); template ICLMath_API std::complex* dft(unsigned int n, icl64f* src); template ICLMath_API icl32c* dft(unsigned int n, icl64f* src); template ICLMath_API icl32c* dft(unsigned int n, icl32c* src); template ICLMath_API std::complex* dft(unsigned int n, icl32c* src); template ICLMath_API std::complex* dft(unsigned int n, std::complex* src); template ICLMath_API icl32c* dft(unsigned int n, std::complex* src); template DynMatrix >& dft2D(DynMatrix &src, DynMatrix >&dst, DynMatrix >&buf){ std::complex *temp=0; for(unsigned int i=0;i(src.cols(),(src.row(i)).data()); //already transposed for(unsigned int j=0;j,T2>(buf.cols(),(buf.row(i)).data()); for(unsigned int j=0;j& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix& src, DynMatrix& dst, DynMatrix& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix >& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix >& dft2D(DynMatrix& src, DynMatrix >& dst, DynMatrix >& buf); template ICLMath_API DynMatrix& dft2D(DynMatrix >& src, DynMatrix& dst, DynMatrix& buf); double e = 0.0; template static std::complex* ifft_(unsigned int n, const T1* a){ if(n==1){ std::complex *cpya = new std::complex[1]; cpya[0] = CreateComplex::create_complex(*a); return cpya; } else if (n%2==0){ unsigned int halfsize = n/2; T1* even = new T1[halfsize]; T1* odd = new T1[halfsize]; unsigned int i; //split array for(i=0;i* g = ifft_(halfsize,even); std::complex* u = ifft_(halfsize,odd); std::complex* c = new std::complex[n]; T2 cp = FFT_2_PI/n; std::complex fac(0.0,0.0); for(unsigned int k=0;k(std::cos(e),std::sin(e)); c[k]=g[k]+fac; c[k+halfsize]=g[k]-fac; } delete[] even; delete[] odd; delete[] g; delete[] u; return c; } else { T2 omega = FFT_2_PI/n; std::complex *m3 = new std::complex[n]; std::complex x(0.0,0.0); T2 y = (T2)0; for(unsigned int p =0;p(0.0,0.0); y=p*omega; for(unsigned int q = 0;q(0.0,y*q))*(CreateComplex::create_complex(a[q]))); x=x+(std::complex(std::cos(y*q),std::sin(y*q))*(CreateComplex::create_complex(a[q]))); } m3[p]=x; } return m3; } } template icl32c* ifft_(unsigned int n, const icl8u* a); template icl32c* ifft_(unsigned int n, const icl16u* a); template icl32c* ifft_(unsigned int n, const icl32u* a); template icl32c* ifft_(unsigned int n, const icl16s* a); template icl32c* ifft_(unsigned int n, const icl32s* a); template icl32c* ifft_(unsigned int n, const icl32f* a); template icl32c* ifft_(unsigned int n, const icl64f* a); template std::complex* ifft_(unsigned int n, const icl8u* a); template std::complex* ifft_(unsigned int n, const icl16u* a); template std::complex* ifft_(unsigned int n, const icl32u* a); template std::complex* ifft_(unsigned int n, const icl16s* a); template std::complex* ifft_(unsigned int n, const icl32s* a); template std::complex* ifft_(unsigned int n, const icl32f* a); template std::complex* ifft_(unsigned int n, const icl64f* a); template icl32c* ifft_(unsigned int n, const icl32c* a); template std::complex* ifft_(unsigned int n, const icl32c* a); template std::complex* ifft_(unsigned int n, const std::complex* a); template icl32c* ifft_(unsigned int n, const std::complex* a); template std::complex* ifft_cpp(unsigned int n, const T1* a){ std::complex* tempMat = ifft_(n,a); double lambda = 1.0/n; for(unsigned int index = 0;index* ifft_cpp(unsigned int n, const icl8u* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl16u* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl32u* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl16s* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl32s* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl32f* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl64f* a); template ICLMath_API icl32c* ifft_cpp(unsigned int n, const icl32c* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const icl32c* a); template ICLMath_API std::complex* ifft_cpp(unsigned int n, const std::complex* a); template ICLMath_API icl32c* ifft_cpp(unsigned int n, const std::complex* a); #ifdef ICL_HAVE_IPP template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException){ FFT_DEBUG("using ipp ifft fc"); int dim = src.cols()*src.rows(); IppiFFTSpec_C_32fc *spec = 0; //IppHintAlgorithm hint; IppStatus status = ippiFFTInitAlloc_C_32fc(&spec,log2(src.cols()),log2(src.rows()), IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate); //or use ippAlgHintNone if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } int minBufSize = 0; ippiFFTGetBufSize_C_32fc(spec,&minBufSize); int currBufSize = dim*sizeof(icl32c)*sizeof(icl32c); Ipp8u *buffer=0; if(currBufSize(buf.data()); Ipp32fc *srcbuf = new Ipp32fc[dim]; const T *srcdata = src.data(); icl32c t(0,0); for(int i=0;i::create_complex(srcdata[i]); Ipp32fc f={t.real(),t.imag()}; srcbuf[i]=f; } int srcStep = src.cols()*sizeof(Ipp32fc); status = ippiFFTInv_CToC_32fc_C1R(srcbuf, srcStep, reinterpret_cast(dst.data()), srcStep, spec, buffer); if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } status = ippiFFTFree_C_32fc(spec); if(status != ippStsOk){ std::string msg = "Error in IPP call!:"; msg +=ippGetStatusString(status); throw FFTException(msg); } return dst; } template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); template DynMatrix& ipp_wrapper_function_result_ifft_icl32fc(const DynMatrix > &src, DynMatrix &dst,DynMatrix &buf) throw(FFTException); #endif #ifdef ICL_HAVE_MKL template DynMatrix >& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException){ FFT_DEBUG("using mkl ifft2d fc"); int dim = src.cols()*src.rows(); unsigned int dimx = src.cols(); unsigned int dimy = src.rows(); MKL_LONG status, l[2]={(MKL_LONG )dimy,(MKL_LONG )dimx}; DFTI_DESCRIPTOR_HANDLE my_desc1_handle=0; status = DftiCreateDescriptor( &my_desc1_handle, getMKLDftiType(), DFTI_COMPLEX, 2,l); MKL_LONG strides_in[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; MKL_LONG strides_out[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; status = DftiSetValue(my_desc1_handle,DFTI_PLACEMENT, DFTI_NOT_INPLACE); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_PACKED_FORMAT, DFTI_PACK_FORMAT); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_INPUT_STRIDES,strides_in); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_OUTPUT_STRIDES,strides_out); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } T2 scale = 1.0/(T2)(dimx*dimy); status = DftiSetValue(my_desc1_handle, DFTI_BACKWARD_SCALE, scale); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiCommitDescriptor( my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiCommitDescriptorError"); } _MKL_Complex8 *srcbuf = new _MKL_Complex8[dim]; std::complex t(0,0); for(int i=0;i::create_complex(src.data()[i]); _MKL_Complex8 temp; temp.real = T2(t.real()); temp.imag = T2(t.imag()); srcbuf[i] = temp; } status = DftiComputeBackward( my_desc1_handle, srcbuf, reinterpret_cast<_MKL_Complex8*>(dst.data())); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiComputeBackwardError"); } status = DftiFreeDescriptor(&my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiFreeDescriptorError"); } delete[] srcbuf; return dst; } template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix& mkl_wrapper_function_result_ifft_icl32fc(const DynMatrix > &src, DynMatrix &dst,DynMatrix &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException){ FFT_DEBUG("using mkl ifft2dfc"); int dim = src.cols()*src.rows(); unsigned int dimx = src.cols(); unsigned int dimy = src.rows(); MKL_LONG status, l[2]={(MKL_LONG )dimy,(MKL_LONG )dimx}; DFTI_DESCRIPTOR_HANDLE my_desc1_handle=0; status = DftiCreateDescriptor( &my_desc1_handle, getMKLDftiType(), DFTI_COMPLEX, 2,l); MKL_LONG strides_in[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; MKL_LONG strides_out[3]={(MKL_LONG )0,(MKL_LONG )dimx,(MKL_LONG )1}; status = DftiSetValue(my_desc1_handle,DFTI_PLACEMENT, DFTI_NOT_INPLACE); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_PACKED_FORMAT, DFTI_PACK_FORMAT); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_INPUT_STRIDES,strides_in); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiSetValue(my_desc1_handle,DFTI_OUTPUT_STRIDES,strides_out); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } T2 scale = 1.0/(T2)(dimx*dimy); status = DftiSetValue(my_desc1_handle, DFTI_BACKWARD_SCALE, scale); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiSetValueError"); } status = DftiCommitDescriptor( my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiCommitDescriptorError"); } _MKL_Complex16 *srcbuf = new _MKL_Complex16[dim]; std::complex t(0,0); for(int i=0;i::create_complex(src.data()[i]); _MKL_Complex16 temp; temp.real = T2(t.real()); temp.imag = T2(t.imag()); srcbuf[i] = temp; } status = DftiComputeBackward( my_desc1_handle, srcbuf, reinterpret_cast<_MKL_Complex16*>(dst.data())); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiComputeBackwardError"); } status = DftiFreeDescriptor(&my_desc1_handle); if(!DftiErrorClass(status,DFTI_NO_ERROR)){ throw FFTException("FFTException DftiFreeDescriptorError"); } delete[] srcbuf; return dst; } template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); template DynMatrix >& mkl_wrapper_function_result_ifft_icl64fc(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buffer) throw(FFTException); #endif template DynMatrix >& ifft2D_cpp(const DynMatrix &src,DynMatrix > &dst,DynMatrix > &buf){ if(buf.isNull() || buf.cols() != src.rows() || buf.rows() != src.cols()){ buf.setBounds(src.rows(),src.cols()); } unsigned int cols = src.cols(); unsigned int rows = src.rows(); std::complex *temp=0; //already transposed for(unsigned int i=0;i(cols,src.row_begin(i)); for(unsigned int j=0;j,T2>(buf.cols(),buf.row_begin(i)); for(unsigned int j=0;j& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D_cpp(const DynMatrix > &src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& ifft2D_cpp(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buf); template DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst, DynMatrix > &buf){ if(isPowerOfTwo(src.cols()) && isPowerOfTwo(src.rows())){ #ifdef ICL_HAVE_IPP buf.setBounds(src.cols(),src.rows()); return ipp_wrapper_function_result_ifft_icl32fc(src,dst,buf); #endif } #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl32fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix &src, DynMatrix &dst, DynMatrix &buf); template ICLMath_API DynMatrix& ifft2D(const DynMatrix > &src, DynMatrix &dst, DynMatrix &buf); //double template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } //complex template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template<> ICLMath_API DynMatrix >& ifft2D(const DynMatrix > &src, DynMatrix > &dst,DynMatrix > &buf){ #ifdef ICL_HAVE_MKL return mkl_wrapper_function_result_ifft_icl64fc(src,dst,buf); #endif return ifft2D_cpp(src,dst,buf); } template std::complex* idft(unsigned int n, T1* src){ std::complex *d = new std::complex[n]; std::complex x= std::complex(0,0); T2 f=FFT_2_PI/n; T2 g = 0.0; T2 h = 1.0/n; T2 k = 0.0; for(unsigned int i=0;i)src[j])*std::complex(std::cos(g),std::sin(g)); } d[i] = x*h; g = 0.0; x = std::complex((T2)0,(T2)0); } return d; } template ICLMath_API icl32c* idft(unsigned int n, icl8u* src); template ICLMath_API std::complex* idft(unsigned int n, icl8u* src); template ICLMath_API icl32c* idft(unsigned int n, icl16u* src); template ICLMath_API std::complex* idft(unsigned int n, icl16u* src); template ICLMath_API icl32c* idft(unsigned int n, icl16s* src); template ICLMath_API std::complex* idft(unsigned int n, icl16s* src); template ICLMath_API icl32c* idft(unsigned int n, icl32u* src); template ICLMath_API std::complex* idft(unsigned int n, icl32u* src); template ICLMath_API icl32c* idft(unsigned int n, icl32s* src); template ICLMath_API std::complex* idft(unsigned int n, icl32s* src); template ICLMath_API icl32c* idft(unsigned int n, icl32f* src); template ICLMath_API std::complex* idft(unsigned int n, icl32f* src); template ICLMath_API std::complex* idft(unsigned int n, icl64f* src); template ICLMath_API icl32c* idft(unsigned int n, icl64f* src); template ICLMath_API icl32c* idft(unsigned int n, icl32c* src); template ICLMath_API std::complex* idft(unsigned int n, icl32c* src); template ICLMath_API std::complex* idft(unsigned int n, std::complex* src); template ICLMath_API icl32c* idft(unsigned int n, std::complex* src); template DynMatrix >& idft2D(DynMatrix& src,DynMatrix > &dst,DynMatrix > &buf){ std::complex *temp = 0; for(unsigned int i=0;i(src.cols(),(src.row(i)).data()); //already transposed for(unsigned int j=0;j,T2>(buf.rows(),(buf.row(i)).data()); for(unsigned int j=0;j& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix& src, DynMatrix &dst,DynMatrix &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix >& idft2D(DynMatrix >& src, DynMatrix > &dst,DynMatrix > &buf); template ICLMath_API DynMatrix& idft2D(DynMatrix >& src, DynMatrix &dst,DynMatrix &buf); } // namespace fft } // namespace math } // namespace icl