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