Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

TDSPfft.h

Go to the documentation of this file.
00001 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef TDSPFFT_H
00019 #define TDSPFFT_H
00020 
00021 #include <TDSPVector.h>
00022 #include <TDSPMatrix.h>
00023 #include <TDSPSignal.h>
00024 #include <TDSPOperator.h>
00025 #include <TDSPOutput1.h>
00026 
00033 class TDSPfft : public TDSPOperator  {
00034 
00035   friend istream &operator>>(istream&,TDSPfft&);
00036   friend ostream &operator<<(ostream&,TDSPfft&);
00037   friend istream &operator>>(istream&,TDSPfft*);
00038   friend ostream &operator<<(ostream&,TDSPfft*);
00039  
00040 
00041  protected:
00042 
00043   static    Bool_t fFFTW; 
00044   Int_t     fDim; 
00045   Double_t  fOverSampling; 
00046   UInt_t    fCyclicPrefix; 
00047 
00048    // my Outputs
00049   TDSPSignal *fFFT_Signal; 
00050   TDSPSignal *fIFFT_Signal; 
00051     
00052   // low level routines from fftw-project
00053   //
00054   void *fftw_vec;         
00055   void *fftw_plan_forward;    
00056   void *fftw_plan_backward;   
00057  
00058 
00059   // my Slots
00060   TString Slot_FFT;
00061   TString Slot_IFFT;
00062 
00063   // my Signals
00064   TString Signal_FFT;
00065   TString Signal_IFFT;
00066 
00067   
00068  public:
00069  
00070   static Bool_t LoadFFTW(); 
00071   static void   EnableFFTW() { fFFTW=kTRUE;}; 
00072   static void   DisableFFTW() { fFFTW=kFALSE;}; 
00073   static Bool_t UsingFFTW()  { return fFFTW;}; 
00074     
00075   // When using tdsp in mex-files - fftw crashes in fftw_destroy_plan...
00076 
00077   static Bool_t _fftw_destroy_plans; 
00078   
00079   void do_fft( TComplex *, 
00080            TComplex *,
00081            Int_t     ndat, 
00082            Int_t     stepin       = 1, 
00083            Int_t     stepout      = 1,
00084            Int_t     cp           = 0,
00085            Double_t  oversampling = 1.0 );
00086  
00087   void do_ifft(TComplex *, 
00088            TComplex *, 
00089            Int_t     ndat, 
00090            Int_t     stepin       = 1, 
00091            Int_t     stepout      = 1,
00092            Int_t     cp           = 0,
00093            Double_t  oversampling = 1.0); 
00094   
00095   TDSPfft(char *name = NULL);
00096   ~TDSPfft();
00097 
00098 
00099   void        SetDim(Int_t d) { fDim=d;}; 
00100   Int_t       GetDim() const { return fDim;};
00101 
00102   TDSPSignal* GetFFTSignal() const { return fFFT_Signal;};
00103   TDSPSignal* GetIFFTSignal() const { return fIFFT_Signal;};
00104    
00105   // Register the slots and the signals of
00106   // fft-object
00107   
00108   void RegisterSignalsAndSlots() {
00109     
00110     // Add the Signals
00111 
00112     Signal_FFT     = AddSignal("FFT(TDSPSignal*)");
00113     Signal_IFFT    = AddSignal("IFFT(TDSPSignal*)");
00114 
00115     // Add the Slots
00116    
00117     Slot_FFT       = AddSlot("FFT(TDSPSignal*)");
00118     Slot_IFFT      = AddSlot("IFFT(TDSPSignal*)");
00119     
00120   }
00121 
00122   // Calculate the fft/ifft of vectors and matrices
00123   //
00124   void         fft(TComplex  *in, TComplex  *out, Int_t l, Int_t stepin=1, Int_t stepout=1);
00125   void        ifft(TComplex  *in, TComplex  *out, Int_t l, Int_t stepin=1, Int_t stepout=1);
00126   TDSPVector*  fft(TDSPVector*in, TDSPVector*out=NULL); 
00127   TDSPMatrix*  fft(TDSPMatrix*in, Int_t dim, TDSPMatrix*out=NULL);
00128 
00129   TDSPVector* ifft(TDSPVector*in, TDSPVector*out=NULL); 
00130   TDSPMatrix* ifft(TDSPMatrix*in, Int_t dim, TDSPMatrix*out=NULL);
00131 
00132   // Slot-Version
00133   //
00134   TDSPSignal* FFT(TDSPSignal *input);
00135   TDSPSignal* IFFT(TDSPSignal *input);
00136   
00137   // Get the Size of the output vector from the IFFT using
00138   // the current settings
00139 
00140   Int_t    GetIFFTLen(Int_t len) {return (Int_t)((len+fCyclicPrefix)*fOverSampling);}; // IFFT-outputlen translation
00141   Int_t    GetFFTLen(Int_t len)  {return (Int_t)((len/fOverSampling)-fCyclicPrefix);};  // FFT-outputlen translation
00142 
00143   // Set/Get the Oversampling Factor
00144   //
00145   void     SetOverSampling(Double_t o) {  fOverSampling = o; }; 
00146   Double_t GetOverSampling() const { return fOverSampling;}; 
00147 
00148   // Set/Get the Size of the Cyclic Prefix
00149   //
00150   void     SetCyclicPrefix(UInt_t c) {  fCyclicPrefix = c; }; 
00151   UInt_t   GetCyclicPrefix() const { return fCyclicPrefix;}; 
00152 
00153   ClassDef(TDSPfft,1)
00154 
00155 };
00156 
00157 // global fft-object
00158 
00159 extern TDSPfft *gFFT; 
00160 
00161 // global fft-routines
00162 
00163 TDSPVector *fft(TDSPVector *in, Int_t N=0, TDSPVector *out = NULL); 
00164 TDSPVector *ifft(TDSPVector *in, Int_t N=0, TDSPVector *out = NULL); 
00165 TDSPMatrix *fft(TDSPMatrix *in, Int_t dim, TDSPMatrix *out = NULL); 
00166 TDSPMatrix *ifft(TDSPMatrix *in, Int_t dim, TDSPMatrix *out = NULL);
00167 
00168 #endif

Generated on Fri Apr 23 16:23:43 2004 by doxygen 1.3.2