?? cfft3.h
字號:
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#ifndef __cfft3__#define __cfft3__#include "cfft2.h"#include "group.h"#include "fiber.h"namespace spectral{ /// Complex three-dimensional FFT object. Computes the normalized complex 3-d FFT /// and its inverse using multi-threaded transforms. /// /// The following example computes the forward and backward transforms on an array /// of complex values and compares the result with the original values. Note the use of /// the alias function template to map the input and output arrays to the same memory /// locations. /// \code /// #include <iostream> /// #include <cfft3.h> /// #include <alloc.h> /// #include <alias.h> /// /// using namespace spectral; /// /// int main() /// { /// int nx=50,ny=60,nz=40; /// int threads=2; /// complex ***a=alloc<complex>(nx,ny,nz); /// complex ***b=alias<complex,complex>(nz,ny,nx,a); /// complex ***c=alloc<complex>(nx,ny,nz); /// cfft3 W(nx,ny,nz,threads); /// real dx=2.0/(real)nx; /// real dy=2.0/(real)ny; /// real dz=2.0/(real)ny; /// for(int i=0;i<nx;i++) /// for(int j=0;j<ny;j++) /// for(int k=0;k<nz;k++) /// a[i][j][k]=c[i][j][k]=complex(-2.0+i*dx+k*dz,-2.0+j*dy-k*dz); /// 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++) /// for(int k=0;k<nz;k++) /// error=max(error,abs(a[i][j][k]-c[i][j][k])); /// std::cout << "error=" << error << std:: endl; /// dealloc<complex>(a); /// dealias<complex>(b); /// dealloc<complex>(c); /// return(0); /// } /// \endcode /// /// \sa rfft3 class cfft3 { public: cfft3(int,int,int,int); cfft3(int,int,int); ~cfft3(); void analysis(complex ***,complex ***); void synthesis(complex ***,complex ***); void analysis(complex ****,complex ****,int); void synthesis(complex ****,complex ****,int); private: /// internal thread object for cfft3 class thread : public fiber { public: thread(int,int,int,int,group*,complex***); ~thread(); void analysis(complex ****,complex ****,int); void synthesis(complex ****,complex ****,int); void wait(); private: group *g; complex ****A; complex ****B; complex ***C; int n1,n2,n3; int m1,m32,p1,p32; int M,P; cfft *FFT1; cfft2 *FFT2; real fac; void start(); enum method {ANALYSIS,SYNTHESIS} Method; }; /// Internal 3-d array used for intermediate transpose complex ***C; /// Internal group pointer for syncing after transpose group *g; /// Number of threads; int threads; /// Pointer array for threads; thread **t; };}#endif// Local Variables:// mode:C++// End:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -