ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TVirtualFFT.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Anna Kreshuk 10/04/2006
3 
4 #ifndef ROOT_TVirtualFFT
5 #define ROOT_TVirtualFFT
6 
7 //////////////////////////////////////////////////////////////////////////
8 //
9 // TVirtualFFT
10 //
11 // TVirtualFFT is an interface class for Fast Fourier Transforms.
12 //
13 //
14 //
15 // The default FFT library is FFTW. To use it, FFTW3 library should already
16 // be installed, and ROOT should be have fftw3 module enabled, with the directories
17 // of fftw3 include file and library specified (see installation instructions).
18 // Function SetDefaultFFT() allows to change the default library.
19 //
20 // Available transform types:
21 // FFT:
22 // - "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT)
23 // in one or more dimensions, -1 in the exponent
24 // - "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT)
25 // in one or more dimensions, +1 in the exponent
26 // - "R2C" - a real-input/complex-output discrete Fourier transform (DFT)
27 // in one or more dimensions,
28 // - "C2R" - inverse transforms to "R2C", taking complex input
29 // (storing the non-redundant half of a logically Hermitian array)
30 // to real output
31 // - "R2HC" - a real-input DFT with output in "halfcomplex" format,
32 // i.e. real and imaginary parts for a transform of size n stored as
33 // r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1
34 // - "HC2R" - computes the reverse of FFTW_R2HC, above
35 // - "DHT" - computes a discrete Hartley transform
36 //
37 // Sine/cosine transforms:
38 // Different types of transforms are specified by parameter kind of the SineCosine() static
39 // function. 4 different kinds of sine and cosine transforms are available
40 // DCT-I (REDFT00 in FFTW3 notation)- kind=0
41 // DCT-II (REDFT10 in FFTW3 notation)- kind=1
42 // DCT-III(REDFT01 in FFTW3 notation)- kind=2
43 // DCT-IV (REDFT11 in FFTW3 notation)- kind=3
44 // DST-I (RODFT00 in FFTW3 notation)- kind=4
45 // DST-II (RODFT10 in FFTW3 notation)- kind=5
46 // DST-III(RODFT01 in FFTW3 notation)- kind=6
47 // DST-IV (RODFT11 in FFTW3 notation)- kind=7
48 // Formulas and detailed descriptions can be found in the chapter
49 // "What FFTW really computes" of the FFTW manual
50 //
51 // NOTE: FFTW computes unnormalized transforms, so doing a transform, followed by its
52 // inverse will give the original array, multiplied by normalization constant
53 // (transform size(N) for FFT, 2*(N-1) for DCT-I, 2*(N+1) for DST-I, 2*N for
54 // other sine/cosine transforms)
55 //
56 // How to use it:
57 // Call to the static function FFT returns a pointer to a fast fourier transform
58 // with requested parameters. Call to the static function SineCosine returns a
59 // pointer to a sine or cosine transform with requested parameters. Example:
60 // {
61 // Int_t N = 10; Double_t *in = new Double_t[N];
62 // TVirtualFFT *fftr2c = TVirtualFFT::FFT(1, &N, "R2C");
63 // fftr2c->SetPoints(in);
64 // fftr2c->Transform();
65 // Double_t re, im;
66 // for (Int_t i=0; i<N; i++)
67 // fftr2c->GetPointComplex(i, re, im);
68 // ...
69 // fftr2c->SetPoints(in2);
70 // ...
71 // fftr2c->SetPoints(in3);
72 // ...
73 // }
74 // Different options are explained in the function comments
75 //
76 //
77 //
78 //
79 //
80 //////////////////////////////////////////////////////////////////////////
81 
82 #ifndef ROOT_TObject
83 #include "TObject.h"
84 #endif
85 
86 #ifndef ROOT_TString
87 #include "TString.h"
88 #endif
89 
90 class TComplex;
91 
92 class TVirtualFFT: public TObject {
93 
94  protected:
95  static TVirtualFFT *fgFFT; //current transformer
96  static TString fgDefault; //default transformer
97 
98  public:
99 
101  virtual ~TVirtualFFT();
102 
103  virtual Int_t *GetN() const = 0;
104 
105  virtual Int_t GetNdim() const = 0;
106  virtual Option_t *GetType() const = 0;
107  virtual Int_t GetSign() const = 0;
108  virtual Option_t *GetTransformFlag() const = 0;
109  virtual void Init(Option_t *flag,Int_t sign, const Int_t *kind) = 0;
110  virtual Bool_t IsInplace() const = 0;
111 
112  virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
113  virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const = 0;
114  virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const = 0;
115  virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
116  virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
117  virtual Double_t* GetPointsReal(Bool_t fromInput=kFALSE) const = 0;
118  virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const = 0;
119  virtual void GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
120 
121  virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0) = 0;
122  virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0) = 0;
123  virtual void SetPoints(const Double_t *data) = 0;
124  virtual void SetPointComplex(Int_t ipoint, TComplex &c) = 0;
125  virtual void SetPointsComplex(const Double_t *re, const Double_t *im) =0;
126  virtual void Transform() = 0;
127 
128  static TVirtualFFT* FFT(Int_t ndim, Int_t *n, Option_t *option);
129  static TVirtualFFT* SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option);
131 
132  static void SetTransform(TVirtualFFT *fft);
133  static const char* GetDefaultFFT();
134  static void SetDefaultFFT(const char *name ="");
135 
136  ClassDef(TVirtualFFT, 0); //abstract interface for FFT calculations
137 };
138 
139 #endif
static void SetTransform(TVirtualFFT *fft)
static: set the current transfrom to parameter
static const char * GetDefaultFFT()
static: return the name of the default fft
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)=0
return c
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t IsInplace() const =0
static TVirtualFFT * GetCurrentTransform()
static: return current fgFFT
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
static TString fgDefault
Definition: TVirtualFFT.h:96
static void SetDefaultFFT(const char *name="")
static: set name of default fft
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)=0
static TVirtualFFT * fgFFT
Definition: TVirtualFFT.h:95
virtual ~TVirtualFFT()
virtual Int_t * GetN() const =0
virtual void SetPointComplex(Int_t ipoint, TComplex &c)=0
ClassDef(TVirtualFFT, 0)
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const =0
virtual void Init(Option_t *flag, Int_t sign, const Int_t *kind)=0
static TVirtualFFT * FFT(Int_t ndim, Int_t *n, Option_t *option)
Returns a pointer to the FFT of requested size and type.
virtual void Transform()=0
virtual Double_t * GetPointsReal(Bool_t fromInput=kFALSE) const =0
virtual Option_t * GetTransformFlag() const =0
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const =0
virtual void SetPoints(const Double_t *data)=0
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition: TVirtualFFT.h:92
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const =0
static TVirtualFFT * SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option)
Returns a pointer to a sine or cosine transform of requested size and kind.
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const =0
double Double_t
Definition: RtypesCore.h:55
virtual Int_t GetSign() const =0
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Int_t GetNdim() const =0
Int_t sign(Double_t x)
Definition: CsgOps.cxx:89
const Int_t n
Definition: legend1.C:16
virtual Option_t * GetType() const =0