Logo ROOT   6.10/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 #include "TVirtualFFT.h"
48 
49 class TComplex;
50 
52  protected:
53  void *fIn; //input array
54  void *fOut; //output array
55  void *fPlan; //fftw plan (the plan how to compute the transform)
56  Int_t fNdim; //number of dimensions
57  Int_t fTotalSize; //total size of the transform
58  Int_t *fN; //transform sizes in each dimension
59  Option_t *fFlags; //transform flags
60 
61  UInt_t MapFlag(Option_t *flag);
62 
63  public:
65  TFFTRealComplex(Int_t n, Bool_t inPlace);
66  TFFTRealComplex(Int_t ndim, Int_t *n, Bool_t inPlace);
67  virtual ~TFFTRealComplex();
68 
69  virtual void Init( Option_t *flags, Int_t /*sign*/,const Int_t* /*kind*/);
70 
71  virtual Int_t GetSize() const {return fTotalSize;}
72  virtual Int_t *GetN() const {return fN;}
73  virtual Int_t GetNdim() const {return fNdim;}
74  virtual Option_t *GetType() const {return "R2C";}
75  virtual Int_t GetSign() const {return 1;}
76  virtual Option_t *GetTransformFlag() const {return fFlags;}
77  virtual Bool_t IsInplace() const {if (fOut) return kTRUE; else return kFALSE;};
78 
79  virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const;
80  virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const;
81  virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const;
82  virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
83  virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const;
84  virtual Double_t *GetPointsReal(Bool_t fromInput=kFALSE) const;
85  virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const ;
86  virtual void GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const ;
87 
88  virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0);
89  virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0);
90  virtual void SetPoints(const Double_t *data);
91  virtual void SetPointComplex(Int_t ipoint, TComplex &c);
92  virtual void SetPointsComplex(const Double_t *re, const Double_t *im);
93  virtual void Transform();
94 
96 };
97 
98 #endif
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...
const char Option_t
Definition: RtypesCore.h:62
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const
Fills the array data with the computed transform.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~TFFTRealComplex()
Destroys the data arrays and the plan.
#define ClassDef(name, id)
Definition: Rtypes.h:297
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...
virtual void Transform()
Computes the transform, specified in Init() function.
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 void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)
Set the point #ipoint.
TFFTRealComplex()
default
virtual Option_t * GetType() const
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
const Bool_t kFALSE
Definition: RtypesCore.h:92
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition: TVirtualFFT.h:88
virtual void SetPoints(const Double_t *data)
Set all input points.
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const
Returns the point #ipoint.
double Double_t
Definition: RtypesCore.h:55
virtual Int_t GetSize() const
UInt_t MapFlag(Option_t *flag)
allowed options: "ES" "M" "P" "EX"
virtual Option_t * GetTransformFlag() const
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual Int_t GetNdim() const
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)
virtual Int_t GetSign() const
virtual Bool_t IsInplace() const
virtual Int_t * GetN() const