Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:33

0001 // @(#)root/base:$Id$
0002 // Author: Anna Kreshuk  10/04/2006
0003 
0004 #ifndef ROOT_TVirtualFFT
0005 #define ROOT_TVirtualFFT
0006 
0007 //////////////////////////////////////////////////////////////////////////
0008 //
0009 // TVirtualFFT
0010 //
0011 // TVirtualFFT is an interface class for Fast Fourier Transforms.
0012 //
0013 //
0014 //
0015 // The default FFT library is FFTW. To use it, FFTW3 library should already
0016 // be installed, and ROOT should be have fftw3 module enabled, with the directories
0017 // of fftw3 include file and library specified (see installation instructions).
0018 // Function SetDefaultFFT() allows to change the default library.
0019 //
0020 // Available transform types:
0021 // FFT:
0022 // - "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT)
0023 //                  in one or more dimensions, -1 in the exponent
0024 // - "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT)
0025 //                  in one or more dimensions, +1 in the exponent
0026 // - "R2C"        - a real-input/complex-output discrete Fourier transform (DFT)
0027 //                  in one or more dimensions,
0028 // - "C2R"        - inverse transforms to "R2C", taking complex input
0029 //                  (storing the non-redundant half of a logically Hermitian array)
0030 //                  to real output
0031 // - "R2HC"       - a real-input DFT with output in "halfcomplex" format,
0032 //                  i.e. real and imaginary parts for a transform of size n stored as
0033 //                  r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1
0034 // - "HC2R"       - computes the reverse of FFTW_R2HC, above
0035 // - "DHT"        - computes a discrete Hartley transform
0036 //
0037 // Sine/cosine transforms:
0038 // Different types of transforms are specified by parameter kind of the SineCosine() static
0039 // function. 4 different kinds of sine and cosine transforms are available
0040 //  DCT-I  (REDFT00 in FFTW3 notation)- kind=0
0041 //  DCT-II (REDFT10 in FFTW3 notation)- kind=1
0042 //  DCT-III(REDFT01 in FFTW3 notation)- kind=2
0043 //  DCT-IV (REDFT11 in FFTW3 notation)- kind=3
0044 //  DST-I  (RODFT00 in FFTW3 notation)- kind=4
0045 //  DST-II (RODFT10 in FFTW3 notation)- kind=5
0046 //  DST-III(RODFT01 in FFTW3 notation)- kind=6
0047 //  DST-IV (RODFT11 in FFTW3 notation)- kind=7
0048 // Formulas and detailed descriptions can be found in the chapter
0049 // "What FFTW really computes" of the FFTW manual
0050 //
0051 // NOTE: FFTW computes unnormalized transforms, so doing a transform, followed by its
0052 //       inverse will give the original array, multiplied by normalization constant
0053 //       (transform size(N) for FFT, 2*(N-1) for DCT-I, 2*(N+1) for DST-I, 2*N for
0054 //       other sine/cosine transforms)
0055 //
0056 // How to use it:
0057 // Call to the static function FFT returns a pointer to a fast fourier transform
0058 // with requested parameters. Call to the static function SineCosine returns a
0059 // pointer to a sine or cosine transform with requested parameters. Example:
0060 // {
0061 //    Int_t N = 10; Double_t *in = new Double_t[N];
0062 //    TVirtualFFT *fftr2c = TVirtualFFT::FFT(1, &N, "R2C");
0063 //    fftr2c->SetPoints(in);
0064 //    fftr2c->Transform();
0065 //    Double_t re, im;
0066 //    for (Int_t i=0; i<N; i++)
0067 //       fftr2c->GetPointComplex(i, re, im);
0068 //    ...
0069 //    fftr2c->SetPoints(in2);
0070 //    ...
0071 //    fftr2c->SetPoints(in3);
0072 //    ...
0073 // }
0074 // Different options are explained in the function comments
0075 //
0076 //
0077 //
0078 //
0079 //
0080 //////////////////////////////////////////////////////////////////////////
0081 
0082 #include "TObject.h"
0083 
0084 #include "TString.h"
0085 
0086 class TComplex;
0087 
0088 class TVirtualFFT: public TObject {
0089 
0090  protected:
0091    static TVirtualFFT *fgFFT;      //current transformer
0092    static TString      fgDefault;  //default transformer
0093 
0094  public:
0095 
0096    TVirtualFFT(){};
0097    virtual ~TVirtualFFT();
0098 
0099    virtual Int_t     *GetN()    const = 0;
0100 
0101    virtual Int_t      GetNdim() const = 0;
0102    virtual Option_t  *GetType() const = 0;
0103    virtual Int_t      GetSign() const = 0;
0104    virtual Option_t  *GetTransformFlag() const = 0;
0105    virtual void       Init(Option_t *flag,Int_t sign, const Int_t *kind) = 0;
0106    virtual Bool_t     IsInplace() const = 0;
0107 
0108    virtual void       GetPoints(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
0109    virtual Double_t   GetPointReal(Int_t ipoint, Bool_t fromInput = kFALSE) const = 0;
0110    virtual Double_t   GetPointReal(const Int_t *ipoint, Bool_t fromInput = kFALSE) const = 0;
0111    virtual void       GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
0112    virtual void       GetPointComplex(const Int_t *ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const = 0;
0113    virtual Double_t*  GetPointsReal(Bool_t fromInput=kFALSE) const = 0;
0114    virtual void       GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput = kFALSE) const = 0;
0115    virtual void       GetPointsComplex(Double_t *data, Bool_t fromInput = kFALSE) const = 0;
0116 
0117    virtual void       SetPoint(Int_t ipoint, Double_t re, Double_t im = 0) = 0;
0118    virtual void       SetPoint(const Int_t *ipoint, Double_t re, Double_t im = 0) = 0;
0119    virtual void       SetPoints(const Double_t *data) = 0;
0120    virtual void       SetPointComplex(Int_t ipoint, TComplex &c) = 0;
0121    virtual void       SetPointsComplex(const Double_t *re, const Double_t *im) =0;
0122    virtual void       Transform() = 0;
0123 
0124    static TVirtualFFT* FFT(Int_t ndim, Int_t *n, Option_t *option);
0125    static TVirtualFFT* SineCosine(Int_t ndim, Int_t *n, Int_t *r2rkind, Option_t *option);
0126    static TVirtualFFT* GetCurrentTransform();
0127 
0128    static void         SetTransform(TVirtualFFT *fft);
0129    static const char*  GetDefaultFFT();
0130    static void         SetDefaultFFT(const char *name ="");
0131 
0132    ClassDefOverride(TVirtualFFT, 0); //abstract interface for FFT calculations
0133 };
0134 
0135 #endif