Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualFFT.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Anna Kreshuk 10/04/2006
3
4#ifndef ROOT_TVirtualFFT
5#define ROOT_TVirtualFFT
6
7//////////////////////////////////////////////////////////////////////////
8//
9// TVirtualFFT
10//
11// TVirtualFFT is an interface class for Fast Fourier Transforms.
12//
13//
14//
15// The default FFT library is FFTW. To use it, FFTW3 library should already
16// be installed, and ROOT should be have fftw3 module enabled, with the directories
17// of fftw3 include file and library specified (see installation instructions).
18// Function SetDefaultFFT() allows to change the default library.
19//
20// Available transform types:
21// FFT:
22// - "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT)
23// in one or more dimensions, -1 in the exponent
24// - "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT)
25// in one or more dimensions, +1 in the exponent
26// - "R2C" - a real-input/complex-output discrete Fourier transform (DFT)
27// in one or more dimensions,
28// - "C2R" - inverse transforms to "R2C", taking complex input
29// (storing the non-redundant half of a logically Hermitian array)
30// to real output
31// - "R2HC" - a real-input DFT with output in "halfcomplex" format,
32// i.e. real and imaginary parts for a transform of size n stored as
33// r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1
34// - "HC2R" - computes the reverse of FFTW_R2HC, above
35// - "DHT" - computes a discrete Hartley transform
36//
37// Sine/cosine transforms:
38// Different types of transforms are specified by parameter kind of the SineCosine() static
39// function. 4 different kinds of sine and cosine transforms are available
40// DCT-I (REDFT00 in FFTW3 notation)- kind=0
41// DCT-II (REDFT10 in FFTW3 notation)- kind=1
42// DCT-III(REDFT01 in FFTW3 notation)- kind=2
43// DCT-IV (REDFT11 in FFTW3 notation)- kind=3
44// DST-I (RODFT00 in FFTW3 notation)- kind=4
45// DST-II (RODFT10 in FFTW3 notation)- kind=5
46// DST-III(RODFT01 in FFTW3 notation)- kind=6
47// DST-IV (RODFT11 in FFTW3 notation)- kind=7
48// Formulas and detailed descriptions can be found in the chapter
49// "What FFTW really computes" of the FFTW manual
50//
51// NOTE: FFTW computes unnormalized transforms, so doing a transform, followed by its
52// inverse will give the original array, multiplied by normalization constant
53// (transform size(N) for FFT, 2*(N-1) for DCT-I, 2*(N+1) for DST-I, 2*N for
54// other sine/cosine transforms)
55//
56// How to use it:
57// Call to the static function FFT returns a pointer to a fast fourier transform
58// with requested parameters. Call to the static function SineCosine returns a
59// pointer to a sine or cosine transform with requested parameters. Example:
60// {
61// Int_t N = 10; Double_t *in = new Double_t[N];
62// TVirtualFFT *fftr2c = TVirtualFFT::FFT(1, &N, "R2C");
63// fftr2c->SetPoints(in);
64// fftr2c->Transform();
65// Double_t re, im;
66// for (Int_t i=0; i<N; i++)
67// fftr2c->GetPointComplex(i, re, im);
68// ...
69// fftr2c->SetPoints(in2);
70// ...
71// fftr2c->SetPoints(in3);
72// ...
73// }
74// Different options are explained in the function comments
75//
76//
77//
78//
79//
80//////////////////////////////////////////////////////////////////////////
81
82#include "TObject.h"
83
84#include "TString.h"
85
86class TComplex;
87
88class TVirtualFFT: public TObject {
89
90 protected:
91 static TVirtualFFT *fgFFT; //current transformer
92 static TString fgDefault; //default transformer
93
94 public:
95
97 virtual ~TVirtualFFT();
98
99 virtual Int_t *GetN() const = 0;
100
101 virtual Int_t GetNdim() const = 0;
102 virtual Option_t *GetType() const = 0;
103 virtual Int_t GetSign() const = 0;
104 virtual Option_t *GetTransformFlag() const = 0;
105 virtual void Init(Option_t *flag,Int_t sign, const Int_t *kind) = 0;
106 virtual Bool_t IsInplace() const = 0;
107
108 virtual void GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
109 virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const = 0;
110 virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const = 0;
111 virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
112 virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
113 virtual Double_t* GetPointsReal(Bool_t fromInput=kFALSE) const = 0;
114 virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const = 0;
115 virtual void GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
116
117 virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im = 0) = 0;
118 virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0) = 0;
119 virtual void SetPoints(const Double_t *data) = 0;
120 virtual void SetPointComplex(Int_t ipoint, TComplex &c) = 0;
121 virtual void SetPointsComplex(const Double_t *re, const Double_t *im) =0;
122 virtual void Transform() = 0;
123
124 static TVirtualFFT* FFT(Int_t ndim, Int_t *n, Option_t *option);
125 static TVirtualFFT* SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option);
127
128 static void SetTransform(TVirtualFFT *fft);
129 static const char* GetDefaultFFT();
130 static void SetDefaultFFT(const char *name ="");
131
132 ClassDefOverride(TVirtualFFT, 0); //abstract interface for FFT calculations
133};
134
135#endif
#define c(i)
Definition RSha256.hxx:101
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
TVirtualFFT is an interface class for Fast Fourier Transforms.
Definition TVirtualFFT.h:88
virtual ~TVirtualFFT()
destructor
static void SetDefaultFFT(const char *name="")
static: set name of default fft
static void SetTransform(TVirtualFFT *fft)
static: set the current transfrom to parameter
virtual Bool_t IsInplace() const =0
virtual void GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const =0
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const =0
virtual Double_t GetPointReal(const Int_t *ipoint, Bool_t fromInput=kFALSE) const =0
virtual void Init(Option_t *flag, Int_t sign, const Int_t *kind)=0
static TVirtualFFT * FFT(Int_t ndim, Int_t *n, Option_t *option)
Returns a pointer to the FFT of requested size and type.
static TVirtualFFT * GetCurrentTransform()
static: return current fgFFT
virtual Int_t GetNdim() const =0
virtual void SetPoints(const Double_t *data)=0
static TVirtualFFT * SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option)
Returns a pointer to a sine or cosine transform of requested size and kind.
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)=0
virtual Option_t * GetTransformFlag() const =0
virtual Option_t * GetType() const =0
virtual void Transform()=0
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const =0
virtual void SetPoint(const Int_t *ipoint, Double_t re, Double_t im=0)=0
virtual void GetPointsComplex(Double_t *data, Bool_t fromInput=kFALSE) const =0
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const =0
virtual Double_t * GetPointsReal(Bool_t fromInput=kFALSE) const =0
virtual Int_t GetSign() const =0
virtual Int_t * GetN() const =0
static TString fgDefault
Definition TVirtualFFT.h:92
virtual void SetPointComplex(Int_t ipoint, TComplex &c)=0
static TVirtualFFT * fgFFT
Definition TVirtualFFT.h:91
virtual Double_t GetPointReal(Int_t ipoint, Bool_t fromInput=kFALSE) const =0
virtual void SetPoint(Int_t ipoint, Double_t re, Double_t im=0)=0
static const char * GetDefaultFFT()
static: return the name of the default fft
const Int_t n
Definition legend1.C:16