📄 rfft2.h
字号:
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#ifndef __rfft2__#define __rfft2__#include "cfft.h"#include "rfft.h"#include "group.h"#include "fiber.h"namespace spectral{ /// Real symmetric two-dimensional FFT object. Computes the normalized 2-d /// FFT of a real valued 2-d array, and it inverse, using multi-threaded transforms. /// /// The following example computes the forward and backward transforms on a real /// array and compares and the result with the original values. /// \code /// #include <iostream> /// #include <rfft2.h> /// #include <alloc.h> /// /// using namespace spectral; /// /// int main() /// { /// int nx=200,ny=300; /// int threads=2; /// real **a=alloc<real>(nx,ny); /// complex **b=alloc<complex>(ny/2+1,nx); /// real **c=alloc<real>(nx,ny); /// rfft2 W(nx,ny,threads); /// real dx=2.0/(real)nx; /// real dy=2.0/(real)ny; /// for(int i=0;i<nx;i++) /// for(int j=0;j<ny;j++) /// a[i][j]=c[i][j]=(-1.0+i*dx)*(-1.0+j*dy); /// W.analysis(a,b); /// W.synthesis(b,a); /// real error=0.0; /// for(int i=0;i<nx;i++) /// for(int j=0;j<ny;j++) /// error=max(error,fabs(a[i][j]-c[i][j])); /// std::cout << "error=" << error << std:: endl; /// dealloc<real>(a); /// dealloc<complex>(b); /// dealloc<real>(c); /// return(0); /// } /// \endcode /// /// \sa cfft2 class rfft2 { public: rfft2(int,int,int); rfft2(int,int); ~rfft2(); void analysis(real ***,complex ***,int,int p=0); void synthesis(complex ***,real ***,int,int p=0); void analysis(real **,complex **); void synthesis(complex **,real **); private: /// internal thread object for rfft2 class thread : public fiber { public: thread(int,int,int,group*); ~thread(); void analysis(real ***,complex ***,int,int); void synthesis(complex ***,real ***,int,int); void wait(); private: int n1; int n2; int N2; int m1,p1; int m2,p2; int M; int P; real ***A; complex ***B; cfft *FFT1; rfft *FFT2; real fac; group *g; void start(); void transpose(real **,complex **); void transpose(complex **,real **); enum method {ANALYSIS,SYNTHESIS} Method; }; int n1; int n2; int N2; int threads; group *g; thread **t; };}#endif// Local Variables:// mode:C++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -