C++ main module for emicrom Package  1.0
MATSGN_FFT.h
Go to the documentation of this file.
1 #ifndef MATSGN_FFT_H
2 #define MATSGN_FFT_H
3 
4 #include "CORE_Object.h"
5 #include "CORE_Array.h"
6 #include "MATSGN_ComplexArray.h"
7 
19 class MATSGN_FFT : public virtual CORE_Object {
21  // ATTRIBUTES
22 
23 public:
24  static const tFlag FXT;
25  static const tFlag SL;
26  static const tFlag LIB_ROW;
27  static const tFlag FFTW;
28 
29  static const tBoolean FORWARD;
30  static const tBoolean BACKWARD;
31  static const tBoolean DIRECT;
32  static const tBoolean INVERSE;
33 
34 
35 private:
37 
38  // ASSOCIATIONS
39 
40 
41 protected:
42  // METHODS
43 
44  // CONSTRUCTORS
45 
47  MATSGN_FFT(void);
48 
49 
50 
51  // DESTRUCTORS
52 
53 
56  virtual ~MATSGN_FFT(void);
57 
58 
59 public:
60 
63  inline static SP::MATSGN_FFT New() {
64  SP::MATSGN_FFT p(new MATSGN_FFT(),MATSGN_FFT::Delete());
65  p->setThis(p);
66  return p;
67  }
68 
69 
70 public:
71 
72  // SET methods
76  inline void setMethod(const tFlag& method) {
77  mMethod=method;
78  };
79 
80  // GET methods
85  static tString getFFTMethodName(const tFlag& m);
86 
87  // OTHERS methods
88 
89 public:
95  void slowFourierTransform(const MATSGN_ComplexArray& input,
96  MATSGN_ComplexArray& output,
97  const tBoolean& isForward) const;
98 
103  inline void slowFourierTransform(const MATSGN_ComplexArray& input,
104  MATSGN_ComplexArray& output) const {
105  slowFourierTransform(input,output,true);
106  }
107 
114  inline static void fastFourierTransform(const CORE_DoubleArray& input,
115  MATSGN_ComplexArray& output,
116  const tFlag& method) {
117  //copy the input into output
118  output=input;
119  MATSGN_FFT::fastFourierTransform(output,output,true,false,method);
120  };
128  inline static void fastFourierTransform(const CORE_DoubleArray& x,
129  MATSGN_ComplexArray& res,
130  const tBoolean& isForward,
131  const tFlag& method) {
132  res=x;
133  fastFourierTransform(res,res,isForward,false,method);
134  };
135 
144  static void fastFourierTransform(const MATSGN_ComplexArray& x,
145  MATSGN_ComplexArray& res,
146  const tBoolean& isForward,
147  const tBoolean& inverse,
148  const tFlag& method);
149 
158  const tBoolean& isForward,
159  const tBoolean& inverse,
160  const tFlag& method);
161 
168  MATSGN_ComplexArray& res) {
169  fastFourierTransform(x,res,true,false,mMethod);
170  };
171 
179  MATSGN_ComplexArray& res,
180  const tFlag& method) {
181  fastFourierTransform(x,res,true,true,method);
182  };
191  MATSGN_ComplexArray& res,
192  const tBoolean& isForward,
193  const tFlag& method) {
194  fastFourierTransform(x,res,isForward,true,method);
195  };
196 
197 
210  virtual tBoolean fastFourierTransform3D(const tUInteger& Nx,
211  const tUInteger& Ny,
212  const tUInteger& Nz,
214  const tBoolean& isForward,
215  const tBoolean& inverse,
216  const tFlag& method) const;
217 
218 protected:
231  const tUInteger& Ny,
232  const tUInteger& Nz,
234  const tBoolean& isForward,
235  const tBoolean& inverse,
236  const tFlag& method) const;
237 
248  virtual tBoolean fastFourierTransform3D_SL(const tUInteger& Nx,
249  const tUInteger& Ny,
250  const tUInteger& Nz,
252  const tBoolean& isForward,
253  const tBoolean& inverse) const;
254 
267  const tUInteger& Ny,
268  const tUInteger& Nz,
270  const tBoolean& isForward,
271  const tBoolean& inverse) const;
272 public:
273 
278  const tUIndex& fromAIndex,
279  MATSGN_ComplexArray& Wrk,
280  const tUInteger& lx,
281  const tUInteger& ly,
282  const tUInteger& lz,
283  const tUInteger& lda,
284  const tBoolean& isForward,
285  const tBoolean& inverse,
286  const tFlag& method) const;
290  const tUInteger& lx,
291  const tUInteger& ly,
292  const tUInteger& lz,
293  const tUInteger& lda,
294  const tBoolean& isForward,
295  const tBoolean& inverse,
296  const tFlag& method) const {
298  wrk.setSize(lx*ly*lz);
299  return fastFourierTransform3DMatrix(A,0,wrk,lx,ly,lz,lda,isForward,inverse,method);
300  }
304  MATSGN_ComplexArray& wrk,
305  const tUInteger& lx,
306  const tUInteger& ly,
307  const tUInteger& lz,
308  const tUInteger& lda,
309  const tBoolean& isForward,
310  const tBoolean& inverse,
311  const tFlag& method) const {
312 
313  return fastFourierTransform3DMatrix(A,0,wrk,lx,ly,lz,lda,isForward,inverse,method);
314  }
315 
316 
317 public:
318 
319  // FXT Method
320  // ===========
330  static void fastFourierTransform_FXT(const MATSGN_ComplexArray& input,
331  const tBoolean& isForward,
332  const tBoolean& isInverse,
333  complex<tDouble>* output);
349  static void fastFourierTransform_FXT(complex<tDouble>* x,const tUIndex& n,
350  const tBoolean& isForward,
351  const tBoolean& isInverse);
352 
353  // FFTW Method
354  // ===========
362  static void Transpose(const tChar& storage,fftw_complex* A, const tUIndex& nRows, const tUIndex& nCols);
363 
378  static void fastFourierTransform_FFTW(const MATSGN_ComplexArray& x,
380  const tBoolean& isForward,
381  const tBoolean& isInverse);
389  const tBoolean& isForward,
390  const tBoolean& isInverse) {
391  fastFourierTransform_FFTW(x.getSize(),&x[0],isForward,isInverse);
392  }
400  static void fastFourierTransform_FFTW(const tUIndex& length,
401  fftw_complex* x,
402  const tBoolean& isForward,
403  const tBoolean& isInverse) ;
404 
425  static void fastFourierTransformND_FFTW(const CORE_IntArray& dims,
427  const tBoolean& isForward,
428  const tBoolean& isInverse) ;
429 
430 
431  // Labbe method
432  // =============
433 public:
438  static void tabfft( const tBoolean& isForward,
440  const tUIndex& nx);
441 
442 public:
449  static void fastFourierTransform_SL(const MATSGN_ComplexArray& w,
451  const tBoolean& isForward,
452  const tBoolean& inverse);
453 private:
454  static tBoolean Rearrange(const MATSGN_ComplexArray& input,
455  MATSGN_ComplexArray& output);
456  static tBoolean Rearrange(MATSGN_ComplexArray& inoutput);
457  static tBoolean Perform(MATSGN_ComplexArray& data,
458  const tBoolean& isForward,
459  const tBoolean& inverse);
460  static tBoolean Scale(MATSGN_ComplexArray& data);
461 
462 
463 
464 public:
465  // LIBROW method
466  // ===============
467  // @see http://www.librow.com/articles/article-10
468  //
469 
480  MATSGN_ComplexArray& output,
481  const tBoolean& isForward,
482  const tBoolean& inverse) ;
483 
484 
485 
495  const tBoolean& isForward,
496  const tBoolean& inverse);
497 
498 
499 
500 
501 };
502 
503 #endif
void setMethod(const tFlag &method)
set the FFT method
Definition: MATSGN_FFT.h:76
DEFINE_SPTR(MATSGN_FFT)
static const tFlag FXT
Definition: MATSGN_FFT.h:24
static const tBoolean INVERSE
Definition: MATSGN_FFT.h:32
static void tabfft(const tBoolean &isForward, MATSGN_ComplexArray &w, const tUIndex &nx)
tabfft
Definition: MATSGN_FFT.cpp:51
static const tFlag FFTW
Definition: MATSGN_FFT.h:27
static void fastFourierTransform_FXT(const MATSGN_ComplexArray &input, const tBoolean &isForward, const tBoolean &isInverse, complex< tDouble > *output)
compute the Fast Fourier Transform of a double complex vector vector using FXT library ...
Definition: MATSGN_FFT.cpp:293
#define tUInteger
Definition: types.h:91
void slowFourierTransform(const MATSGN_ComplexArray &input, MATSGN_ComplexArray &output, const tBoolean &isForward) const
compute the fourier transform basicly (slow fourier transform)
Definition: MATSGN_FFT.cpp:507
static const tFlag LIB_ROW
Definition: MATSGN_FFT.h:26
This class describes FFT routines based on fftw_complex array used in fftw library.
Definition: MATSGN_FFT.h:19
virtual tBoolean fastFourierTransform3DMatrix(MATSGN_ComplexArray &A, const tUInteger &lx, const tUInteger &ly, const tUInteger &lz, const tUInteger &lda, const tBoolean &isForward, const tBoolean &inverse, const tFlag &method) const
compute the 3D fft in a mesh
Definition: MATSGN_FFT.h:289
This class describes FFT complex array based on fft_complex structure.
Definition: MATSGN_ComplexArray.h:16
static void fastFourierTransform_FFTW(const MATSGN_ComplexArray &x, MATSGN_ComplexArray &y, const tBoolean &isForward, const tBoolean &isInverse)
compute the Fast Fourier Transform of a double complex vector vector using FFTW library ...
Definition: MATSGN_FFT.cpp:196
static void fastFourierTransform_FFTW(MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &isInverse)
compute the Fast Fourier Transform of a double complex vector using FFTW library
Definition: MATSGN_FFT.h:388
void slowFourierTransform(const MATSGN_ComplexArray &input, MATSGN_ComplexArray &output) const
compute the fourier transform basicly (slow fourier transform)
Definition: MATSGN_FFT.h:103
virtual tBoolean fastFourierTransform3D_FFTW(const tUInteger &Nx, const tUInteger &Ny, const tUInteger &Nz, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &inverse) const
compute a complex fft for an array 3D usinf FFTW
Definition: MATSGN_FFT.cpp:655
virtual tBoolean fastFourierTransform3DMatrix(MATSGN_ComplexArray &A, MATSGN_ComplexArray &wrk, const tUInteger &lx, const tUInteger &ly, const tUInteger &lz, const tUInteger &lda, const tBoolean &isForward, const tBoolean &inverse, const tFlag &method) const
compute the 3D fft in a mesh
Definition: MATSGN_FFT.h:303
#define tBoolean
Definition: types.h:139
static void fastFourierTransformND_FFTW(const CORE_IntArray &dims, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &isInverse)
compute the Fast Fourier Transform of a double complex vector with dimensions dims using FFTW library...
Definition: MATSGN_FFT.cpp:252
static tBoolean Perform(MATSGN_ComplexArray &data, const tBoolean &isForward, const tBoolean &inverse)
Definition: MATSGN_FFT.cpp:588
static tBoolean Rearrange(const MATSGN_ComplexArray &input, MATSGN_ComplexArray &output)
Definition: MATSGN_FFT.cpp:561
virtual tBoolean fastFourierTransform3D_SL(const tUInteger &Nx, const tUInteger &Ny, const tUInteger &Nz, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &inverse) const
compute a complex fft for an array 3D used in SL fortran code
Definition: MATSGN_FFT.cpp:870
static const tBoolean FORWARD
Definition: MATSGN_FFT.h:29
static void Transpose(const tChar &storage, fftw_complex *A, const tUIndex &nRows, const tUIndex &nCols)
transpose a complex matric sotored in Array or Column of size nRows x nCols
Definition: MATSGN_FFT.cpp:162
static const tBoolean DIRECT
Definition: MATSGN_FFT.h:31
SP_OBJECT(MATSGN_FFT)
const tUIndex & getSize() const
get the size
Definition: MATSGN_ComplexArray.h:385
void fastFourierInverseTransform(const MATSGN_ComplexArray &x, MATSGN_ComplexArray &res, const tFlag &method)
compute the Fast Fourier Transform inverse of a complex vector in the forwrd direction ...
Definition: MATSGN_FFT.h:178
virtual ~MATSGN_FFT(void)
destroy an FFT Object.
Definition: MATSGN_FFT.cpp:29
static tBoolean fastFourierTransform_LR(const MATSGN_ComplexArray &input, MATSGN_ComplexArray &output, const tBoolean &isForward, const tBoolean &inverse)
compute the fast fourier transform of input using LIBROW algorithm
Definition: MATSGN_FFT.cpp:537
static const tFlag SL
Definition: MATSGN_FFT.h:25
this class describes an array
Definition: CORE_Array.h:19
static SP::MATSGN_FFT New()
create a FFT class
Definition: MATSGN_FFT.h:63
tFlag mMethod
Definition: MATSGN_FFT.h:36
void fastFourierInverseTransform(const MATSGN_ComplexArray &x, MATSGN_ComplexArray &res, const tBoolean &isForward, const tFlag &method)
compute the Fast Fourier Transform inverse of a complex vector
Definition: MATSGN_FFT.h:190
void setSize(const tUIndex &n)
set size of the array
Definition: MATSGN_ComplexArray.h:333
#define tUIndex
Definition: types.h:126
virtual tBoolean fastFourierTransform3D_GENERIC(const tUInteger &Nx, const tUInteger &Ny, const tUInteger &Nz, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &inverse, const tFlag &method) const
compute a complex fft for an array 3D
Definition: MATSGN_FFT.cpp:431
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
#define tChar
Definition: types.h:23
static tString getFFTMethodName(const tFlag &m)
get the method name
Definition: MATSGN_FFT.cpp:33
MATSGN_FFT(void)
create a FFT object
Definition: MATSGN_FFT.cpp:24
static const tBoolean BACKWARD
Definition: MATSGN_FFT.h:30
virtual tBoolean fastFourierTransform3DMatrix(MATSGN_ComplexArray &A, const tUIndex &fromAIndex, MATSGN_ComplexArray &Wrk, const tUInteger &lx, const tUInteger &ly, const tUInteger &lz, const tUInteger &lda, const tBoolean &isForward, const tBoolean &inverse, const tFlag &method) const
compute the 3D fft in a mesh translation of ZZFFT
Definition: MATSGN_FFT.cpp:974
static tBoolean Scale(MATSGN_ComplexArray &data)
Definition: MATSGN_FFT.cpp:643
void fastFourierTransform(const MATSGN_ComplexArray &x, MATSGN_ComplexArray &res)
compute the Fast Fourier Transform of a complex vector in the forward direction
Definition: MATSGN_FFT.h:167
static void fastFourierTransform_SL(const MATSGN_ComplexArray &w, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &inverse)
compute the fft transform of vector x translated from fft.h from Stephane Labbé EM62 code ...
Definition: MATSGN_FFT.cpp:350
static void fastFourierTransform(const CORE_DoubleArray &x, MATSGN_ComplexArray &res, const tBoolean &isForward, const tFlag &method)
compute the Fast Fourier Transform of a double vector
Definition: MATSGN_FFT.h:128
static void fastFourierTransform(const CORE_DoubleArray &input, MATSGN_ComplexArray &output, const tFlag &method)
compute the Fast Fourier Transform of a double vector with respect to the method
Definition: MATSGN_FFT.h:114
virtual tBoolean fastFourierTransform3D(const tUInteger &Nx, const tUInteger &Ny, const tUInteger &Nz, MATSGN_ComplexArray &x, const tBoolean &isForward, const tBoolean &inverse, const tFlag &method) const
compute a complex fft for an array 3D
Definition: MATSGN_FFT.cpp:67
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74