Logo ROOT   6.13/01
Reference Guide
TFFTReal.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_TFFTReal
13 #define ROOT_TFFTReal
14 
15 //////////////////////////////////////////////////////////////////////////
16 //
17 // TFFTReal
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 //
21 // Computes transforms called r2r in FFTW manual:
22 // - transforms of real input and output in "halfcomplex" format i.e.
23 // real and imaginary parts for a transform of size n stored as
24 // (r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1)
25 // - discrete Hartley transform
26 // - sine and cosine transforms (DCT-I,II,III,IV and DST-I,II,III,IV)
27 // For the detailed information on the computed
28 // transforms please refer to the FFTW manual, chapter "What FFTW really computes".
29 //
30 // How to use it:
31 // 1) Create an instance of TFFTReal - this will allocate input and output
32 // arrays (unless an in-place transform is specified)
33 // 2) Run the Init() function with the desired flags and settings (see function
34 // comments for possible kind parameters)
35 // 3) Set the data (via SetPoints()or SetPoint() functions)
36 // 4) Run the Transform() function
37 // 5) Get the output (via GetPoints() or GetPoint() functions)
38 // 6) Repeat steps 3)-5) as needed
39 // For a transform of the same size, but of different kind (or with different flags),
40 // rerun the Init() function and continue with steps 3)-5)
41 //
42 // NOTE: 1) running Init() function will overwrite the input array! Don't set any data
43 // before running the Init() function!
44 // 2) FFTW computes unnormalized transform, so doing a transform followed by
45 // its inverse will lead to the original array scaled BY:
46 // - transform size (N) for R2HC, HC2R, DHT transforms
47 // - 2*(N-1) for DCT-I (REDFT00)
48 // - 2*(N+1) for DST-I (RODFT00)
49 // - 2*N for the remaining transforms
50 // Transform inverses:
51 // R2HC<-->HC2R
52 // DHT<-->DHT
53 // DCT-I<-->DCT-I
54 // DCT-II<-->DCT-III
55 // DCT-IV<-->DCT-IV
56 // DST-I<-->DST-I
57 // DST-II<-->DST-III
58 // DST-IV<-->DST-IV
59 //
60 //////////////////////////////////////////////////////////////////////////
61 
62 #include "TVirtualFFT.h"
63 #include "TString.h"
64 
65 class TComplex;
66 
67 class TFFTReal: public TVirtualFFT{
68  protected:
69  void *fIn; //input array
70  void *fOut; //output array
71  void *fPlan; //fftw plan (the plan how to compute the transform)
72  Int_t fNdim; //number of dimensions
73  Int_t fTotalSize; //total size of the transform
74  Int_t *fN; //transform sizes in each dimension
75  void *fKind; //transform kinds in each dimension
76  TString fFlags; //transform flags
77 
78  Int_t MapOptions(const Int_t *kind);
79  UInt_t MapFlag(Option_t *flag);
80 
81  public:
82  TFFTReal();
83  TFFTReal(Int_t n, Bool_t inPlace=kFALSE);
84  TFFTReal(Int_t ndim, Int_t *n, Bool_t inPlace=kFALSE);
85  virtual ~TFFTReal();
86 
87  virtual void Init( Option_t *flags,Int_t sign, const Int_t *kind);
88 
89  virtual Int_t GetSize() const {return fTotalSize;}
90  virtual Int_t *GetN() const {return fN;}
91  virtual Int_t GetNdim() const {return fNdim;}
92  virtual Option_t *GetType() const;
93  virtual Int_t GetSign() const {return 0;}
94  virtual Option_t *GetTransformFlag() const {return fFlags;}
95  virtual Bool_t IsInplace() const {if (fOut) return kTRUE; else return kFALSE;}
96 
97  virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const;
98  virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const;
99  virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const;
100  virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
101 
102  virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
103 
104  virtual Double_t *GetPointsReal(Bool_t fromInput=kFALSE) const;
105  virtual void GetPointsComplex(Double_t* /*re*/, Double_t* /*im*/, Bool_t /*fromInput = kFALSE*/) const{};
106  virtual void GetPointsComplex(Double_t* /*data*/, Bool_t /*fromInput = kFALSE*/) const {};
107 
108  virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0);
109  virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t /*im=0*/);
110  virtual void SetPoints(const Double_t *data);
111  virtual void SetPointComplex(Int_t /*ipoint*/, TComplex &/*c*/){};
112  virtual void SetPointsComplex(const Double_t* /*re*/, const Double_t* /*im*/){};
113  virtual void Transform();
114 
115 
116  ClassDef(TFFTReal,0);
117 };
118 
119 #endif
virtual void SetPoints(const Double_t *data)
Sets all points.
Definition: TFFTReal.cxx:339
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const
For 1d tranforms. Returns point #ipoint.
Definition: TFFTReal.cxx:228
Int_t * fN
Definition: TFFTReal.h:74
void * fOut
Definition: TFFTReal.h:70
virtual Double_t * GetPointsReal(Bool_t fromInput=kFALSE) const
Returns the output (or input) array.
Definition: TFFTReal.cxx:282
virtual Option_t * GetType() const
Returns the type of the transform.
Definition: TFFTReal.cxx:202
virtual Int_t GetNdim() const
Definition: TFFTReal.h:91
virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const
Only for input of HC2R and output of R2HC and for 1d.
Definition: TFFTReal.cxx:274
void * fIn
Definition: TFFTReal.h:69
Int_t MapOptions(const Int_t *kind)
transfers the r2r_kind parameters to fftw type
Definition: TFFTReal.cxx:348
UInt_t MapFlag(Option_t *flag)
allowed options: "ES" - FFTW_ESTIMATE "M" - FFTW_MEASURE "P" - FFTW_PATIENT "EX" - FFTW_EXHAUSTIVE ...
Definition: TFFTReal.cxx:394
virtual void Init(Option_t *flags, Int_t sign, const Int_t *kind)
Creates the fftw-plan.
Definition: TFFTReal.cxx:168
virtual void SetPointComplex(Int_t, TComplex &)
Definition: TFFTReal.h:111
void * fKind
Definition: TFFTReal.h:75
virtual Option_t * GetTransformFlag() const
Definition: TFFTReal.h:94
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)
Definition: TFFTReal.cxx:302
virtual void GetPointsComplex(Double_t *, Double_t *, Bool_t) const
Definition: TFFTReal.h:105
TFFTReal()
default
Definition: TFFTReal.cxx:67
Int_t fNdim
Definition: TFFTReal.h:72
virtual Bool_t IsInplace() const
Definition: TFFTReal.h:95
virtual ~TFFTReal()
clean-up
Definition: TFFTReal.cxx:122
virtual void SetPointsComplex(const Double_t *, const Double_t *)
Definition: TFFTReal.h:112
virtual Int_t GetSize() const
Definition: TFFTReal.h:89
virtual Int_t * GetN() const
Definition: TFFTReal.h:90
Int_t fTotalSize
Definition: TFFTReal.h:73
TString fFlags
Definition: TFFTReal.h:76
virtual void Transform()
Computes the transform, specified in Init() function.
Definition: TFFTReal.cxx:189
virtual void GetPointsComplex(Double_t *, Bool_t) const
Definition: TFFTReal.h:106
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const
Copies the output (or input) points into the provided array, that should be big enough.
Definition: TFFTReal.cxx:218
void * fPlan
Definition: TFFTReal.h:71
virtual Int_t GetSign() const
Definition: TFFTReal.h:93