⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfft2.h

📁 The Spectral Toolkit is a C++ spectral transform library written by Rodney James and Chuck Panaccion
💻 H
字号:
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#ifndef __cfft2__#define __cfft2__#include "cfft.h"#include "group.h"#include "fiber.h"namespace spectral{  /// Complex two-dimensional FFT object.  Computes the normalized complex 2-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.  /// \code  /// #include <iostream>  /// #include <cfft2.h>  /// #include <alloc.h>  ///   /// using namespace spectral;  ///   /// int main()  /// {  ///   int nx=200,ny=300;  ///   int threads=2;  ///   complex **a=alloc<complex>(nx,ny);  ///   complex **b=alloc<complex>(ny,nx);  ///   complex **c=alloc<complex>(nx,ny);  ///   cfft2 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]=complex(-2.0+i*dx,-2.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,abs(a[i][j]-c[i][j]));  ///   std::cout << "error=" << error << std:: endl;  ///   dealloc<complex>(a);  ///   dealloc<complex>(b);  ///   dealloc<complex>(c);  ///   return(0);  /// }  /// \endcode  ///  /// \sa rfft2   class cfft2  {  public:    cfft2(int,int,int);    cfft2(int,int);    ~cfft2();              void analysis(complex ***,complex ***,int,int p=0);    void synthesis(complex ***,complex ***,int,int p=0);    void analysis(complex **,complex **);    void synthesis(complex **,complex **);  private:    /// Internal thread object.    class thread : public fiber    {    public:      thread(int,int,int,group*);      ~thread();      void analysis(complex ***,complex ***,int,int);      void synthesis(complex ***,complex ***,int,int);      void wait();    private:      int n1;      int n2;      int m1,p1;      int m2,p2;      int M;      int P;      complex ***A;      complex ***B;      cfft *FFT1;      cfft *FFT2;      real fac;      group *g;      void start();      enum method {ANALYSIS,SYNTHESIS} Method;    };    /// Internal group object.    group *g;    /// Number of threads.    int threads;    /// Array of thread objects.    thread **t;  };}#endif// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -