Logo ROOT   6.12/07
Reference Guide
TFFTComplex.h
Go to the documentation of this file.
1 // @(#)root/fft:$Id$
2 // Author: Anna Kreshuk 07/4/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TFFTComplex
13 #define ROOT_TFFTComplex
14 
15 //////////////////////////////////////////////////////////////////////////
16 //
17 // TFFTComplex
18 // One of the interface classes to the FFTW package, can be used directly
19 // or via the TVirtualFFT class. Only the basic interface of FFTW is implemented.
20 // Computes complex input/output discrete Fourier transforms (DFT)
21 // in one or more dimensions. For the detailed information on the computed
22 // transforms please refer to the FFTW manual, chapter "What FFTW really computes".
23 //
24 // How to use it:
25 // 1) Create an instance of TFFTComplex - this will allocate input and output
26 // arrays (unless an in-place transform is specified)
27 // 2) Run the Init() function with the desired flags and settings
28 // 3) Set the data (via SetPoints(), SetPoint() or SetPointComplex() functions)
29 // 4) Run the Transform() function
30 // 5) Get the output (via GetPoints(), GetPoint() or GetPointComplex() functions)
31 // 6) Repeat steps 3)-5) as needed
32 //
33 // For a transform of the same size, but with different flags or sign, rerun the Init()
34 // function and continue with steps 3)-5)
35 // NOTE: 1) running Init() function will overwrite the input array! Don't set any data
36 // before running the Init() function
37 // 2) FFTW computes unnormalized transform, so doing a transform followed by
38 // its inverse will lead to the original array scaled by the transform size
39 //
40 //////////////////////////////////////////////////////////////////////////
41 
42 #include "TVirtualFFT.h"
43 #include "TString.h"
44 
45 class TComplex;
46 
47 class TFFTComplex : public TVirtualFFT{
48 protected:
49  void *fIn; //input array
50  void *fOut; //output array
51  void *fPlan; //fftw plan (the plan how to compute the transform)
52  Int_t fNdim; //number of dimensions
53  Int_t fTotalSize; //total size of the transform
54  Int_t *fN; //transform sizes in each dimension
55  Int_t fSign; //sign of the exponent of the transform (-1 is FFTW_FORWARD and +1 FFTW_BACKWARD)
56  TString fFlags; //transform flags
57 
58  UInt_t MapFlag(Option_t *flag);
59 
60 public:
61  TFFTComplex();
62  TFFTComplex(Int_t n, Bool_t inPlace);
63  TFFTComplex(Int_t ndim, Int_t *n, Bool_t inPlace = kFALSE);
64  virtual ~TFFTComplex();
65 
66  virtual void Init(Option_t *flags, Int_t sign, const Int_t* /*kind*/);
67 
68  virtual Int_t *GetN() const {return fN;}
69  virtual Int_t GetNdim() const {return fNdim;}
70  virtual Int_t GetSize() const {return fTotalSize;}
71  virtual Option_t *GetType() const {if (fSign==-1) return "C2CBackward"; else return "C2CForward";}
72  virtual Int_t GetSign() const {return fSign;}
73  virtual Option_t *GetTransformFlag() const {return fFlags;}
74  virtual Bool_t IsInplace() const {if (fOut) return kTRUE; else return kFALSE;};
75 
76  virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const;
77  virtual Double_t GetPointReal(Int_t /*ipoint*/, Bool_t /*fromInput = kFALSE*/) const {return 0;};
78  virtual Double_t GetPointReal(const Int_t* /*ipoint*/, Bool_t /*fromInput=kFALSE*/) const{return 0;}
79  virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
80  virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
81  virtual Double_t* GetPointsReal(Bool_t /*fromInput=kFALSE*/) const {return 0;};
82  virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const ;
83  virtual void GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const ;
84 
85  virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0);
86  virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0);
87  virtual void SetPoints(const Double_t *data);
88  virtual void SetPointComplex(Int_t ipoint, TComplex &c);
89  virtual void SetPointsComplex(const Double_t *re, const Double_t *im);
90  virtual void Transform();
91 
93 };
94 
95 #endif
virtual Int_t GetSize() const
Definition: TFFTComplex.h:70
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const
Copies real and imaginary parts of the output (input) into the argument arrays.
void * fIn
Definition: TFFTComplex.h:49
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)
sets real and imaginary parts of point # ipoint
virtual void Init(Option_t *flags, Int_t sign, const Int_t *)
Creates the fftw-plan.
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t GetNdim() const
Definition: TFFTComplex.h:69
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const
returns real and imaginary parts of the point #ipoint
Basic string class.
Definition: TString.h:125
virtual Option_t * GetType() const
Definition: TFFTComplex.h:71
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Int_t * GetN() const
Definition: TFFTComplex.h:68
Int_t fTotalSize
Definition: TFFTComplex.h:53
virtual void SetPointComplex(Int_t ipoint, TComplex &c)
#define ClassDef(name, id)
Definition: Rtypes.h:320
Int_t fNdim
Definition: TFFTComplex.h:52
Int_t fSign
Definition: TFFTComplex.h:55
virtual void Transform()
Computes the transform, specified in Init() function.
virtual Int_t GetSign() const
Definition: TFFTComplex.h:72
virtual Bool_t IsInplace() const
Definition: TFFTComplex.h:74
UInt_t MapFlag(Option_t *flag)
allowed options: "ES" - FFTW_ESTIMATE "M" - FFTW_MEASURE "P" - FFTW_PATIENT "EX" - FFTW_EXHAUSTIVE ...
TFFTComplex()
default
Definition: TFFTComplex.cxx:49
unsigned int UInt_t
Definition: RtypesCore.h:42
void * fOut
Definition: TFFTComplex.h:50
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const
Copies the output(or input) into the argument array.
const Bool_t kFALSE
Definition: RtypesCore.h:88
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition: TVirtualFFT.h:88
virtual ~TFFTComplex()
Destroys the data arrays and the plan.
virtual Double_t GetPointReal(Int_t, Bool_t) const
Definition: TFFTComplex.h:77
double Double_t
Definition: RtypesCore.h:55
virtual Double_t GetPointReal(const Int_t *, Bool_t) const
Definition: TFFTComplex.h:78
virtual void SetPoints(const Double_t *data)
set all points.
virtual Option_t * GetTransformFlag() const
Definition: TFFTComplex.h:73
Int_t * fN
Definition: TFFTComplex.h:54
void * fPlan
Definition: TFFTComplex.h:51
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)
set all points. the values are copied
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
virtual Double_t * GetPointsReal(Bool_t) const
Definition: TFFTComplex.h:81
TString fFlags
Definition: TFFTComplex.h:56