Logo ROOT   6.10/09
Reference Guide
TFFTComplexReal.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_TFFTComplexReal
13 #define ROOT_TFFTComplexReal
14 
15 //////////////////////////////////////////////////////////////////////////
16 //
17 // TFFTComplexReal
18 //
19 // One of the interface classes to the FFTW package, can be used directly
20 // or via the TVirtualFFT class. Only the basic interface of FFTW is implemented.
21 //
22 // Computes the inverse of the real-to-complex transforms (class TFFTRealComplex)
23 // taking complex input (storing the non-redundant half of a logically Hermitian array)
24 // to real output (see FFTW manual for more details)
25 //
26 // How to use it:
27 // 1) Create an instance of TFFTComplexReal - this will allocate input and output
28 // arrays (unless an in-place transform is specified)
29 // 2) Run the Init() function with the desired flags and settings
30 // 3) Set the data (via SetPoints(), SetPoint() or SetPointComplex() functions)
31 // 4) Run the Transform() function
32 // 5) Get the output (via GetPoints(), GetPoint() or GetPointReal() functions)
33 // 6) Repeat steps 3)-5) as needed
34 //
35 // For a transform of the same size, but with different flags, rerun the Init()
36 // function and continue with steps 3)-5)
37 // NOTE: 1) running Init() function will overwrite the input array! Don't set any data
38 // before running the Init() function
39 // 2) FFTW computes unnormalized transform, so doing a transform followed by
40 // its inverse will lead to the original array scaled by the transform size
41 //
42 //////////////////////////////////////////////////////////////////////////
43 
44 #include "TVirtualFFT.h"
45 
46 class TComplex;
47 
49 
50  protected:
51  void *fIn; //input array
52  void *fOut; //output array
53  void *fPlan; //fftw plan (the plan how to compute the transform)
54  Int_t fNdim; //number of dimensions
55  Int_t fTotalSize; //total size of the transform
56  Int_t *fN; //transform sizes in each dimension
57  Option_t *fFlags; //transform flags
58 
59  UInt_t MapFlag(Option_t *flag);
60 
61  public:
63  TFFTComplexReal(Int_t n, Bool_t inPlace);
64  TFFTComplexReal(Int_t ndim, Int_t *n, Bool_t inPlace);
65  virtual ~TFFTComplexReal();
66 
67  virtual void Init( Option_t *flags, Int_t /*sign*/,const Int_t* /*kind*/);
68 
69  virtual Int_t GetSize() const {return fTotalSize;}
70  virtual Int_t *GetN() const {return fN;}
71  virtual Int_t GetNdim() const {return fNdim;}
72  virtual Option_t *GetType() const {return "C2R";}
73  virtual Int_t GetSign() const {return -1;}
74  virtual Option_t *GetTransformFlag() const {return fFlags;}
75  virtual Bool_t IsInplace() const {if (fOut) return kTRUE; else return kFALSE;};
76 
77  virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const;
78  virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const;
79  virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const;
80  virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
81  virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
82  virtual Double_t* GetPointsReal(Bool_t fromInput=kFALSE) const;
83  virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const ;
84  virtual void GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const ;
85 
86  virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0);
87  virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0);
88  virtual void SetPoints(const Double_t *data);
89  virtual void SetPointComplex(Int_t ipoint, TComplex &c);
90  virtual void SetPointsComplex(const Double_t *re, const Double_t *im);
91  virtual void Transform();
92 
94 };
95 
96 #endif
virtual Double_t * GetPointsReal(Bool_t fromInput=kFALSE) const
Returns the array of computed transform Works only for output (input array is destroyed in a C2R tran...
virtual void SetPointComplex(Int_t ipoint, TComplex &c)
since the input must be complex-Hermitian, if the ipoint > n/2, the according point before n/2 is set...
const char Option_t
Definition: RtypesCore.h:62
virtual Option_t * GetTransformFlag() const
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t IsInplace() const
TFFTComplexReal()
default
virtual Option_t * GetType() const
virtual Int_t * GetN() const
virtual void Init(Option_t *flags, Int_t, const Int_t *)
Creates the fftw-plan.
virtual ~TFFTComplexReal()
Destroys the data arrays and the plan.
#define ClassDef(name, id)
Definition: Rtypes.h:297
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const
Works only for output (input array is destroyed in a C2R transform)
virtual void SetPoints(const Double_t *data)
set all points.
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)
since the input must be complex-Hermitian, if the ipoint > n/2, the according point before n/2 is set...
virtual void Transform()
Computes the transform, specified in Init() function.
Option_t * fFlags
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const
Returns the point #ipoint Works only for output (input array is destroyed in a C2R transform) ...
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const
Fills the argument array with the computed transform Works only for output (input array is destroyed ...
virtual Int_t GetNdim() const
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:92
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition: TVirtualFFT.h:88
UInt_t MapFlag(Option_t *flag)
allowed options: "ES" - FFTW_ESTIMATE "M" - FFTW_MEASURE "P" - FFTW_PATIENT "EX" - FFTW_EXHAUSTIVE ...
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)
Set all points. The values are copied.
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const
Fills the argument array with the computed transform Works only for output (input array is destroyed ...
double Double_t
Definition: RtypesCore.h:55
virtual Int_t GetSize() const
virtual Int_t GetSign() const
const Bool_t kTRUE
Definition: RtypesCore.h:91
const Int_t n
Definition: legend1.C:16