source: Sophya/trunk/SophyaLib/NTools/fftservintf.h@ 2532

Last change on this file since 2532 was 2526, checked in by cmv, 21 years ago

methodes inline donnant la taille du vecteur FFT cmv 22/04/04

File size: 4.2 KB
RevLine 
[1371]1// FFT (Fast Fourier Transform) Server Interface
2// R. Ansari 1999-2000
3// DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
4
[710]5#ifndef FFTServerIntf_H_SEEN
6#define FFTServerIntf_H_SEEN
7
8#include "machdefs.h"
9#include "pexceptions.h"
10#include <complex>
11#include "tmatrix.h"
12#include "tvector.h"
13
14// Classe definissant l'interface pour les transformees de Fourier
15// L'implementation par defaut est vide et lance une exception
16
17namespace SOPHYA {
18
19class FFTServerInterface {
20 public:
21
22// Methodes de la classe
23 FFTServerInterface(string info);
24 virtual ~FFTServerInterface();
25
26
27 virtual FFTServerInterface * Clone() = 0;
28
[2526]29 //! Set/clear the flag for normalizing Fourier transforms.
[710]30 inline void setNormalize(bool fg=false) { _fgnorm = fg; }
[2526]31 //! Returns the status of normalization flag for the server
[710]32 inline bool getNormalize() const { return(_fgnorm); }
[2526]33 //! Returns the information string associated with the server
[710]34 inline string getInfo() const { return _info; }
35
36 //---------------------------------------------------
[1390]37 // Transforme N-dim sur des doubles
[2526]38 virtual void FFTForward(TArray<r_4> const & in, TArray< complex<r_4> > & out);
39 virtual void FFTForward(TArray<r_8> const & in, TArray< complex<r_8> > & out);
40 virtual void FFTForward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
[1390]41 virtual void FFTForward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
[2526]42
43 virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray<r_4> & out,bool usoutsz=false);
44 virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray<r_8> & out,bool usoutsz=false);
45 virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
[1390]46 virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
[1630]47
48 //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
[2526]49 virtual r_8 TransfEnergyFFT(TVector<r_4> const & x, TVector< complex<r_4> > const& fftx,r_8& A,r_8& B);
50 virtual r_8 TransfEnergyFFT(TVector<r_8> const & x, TVector< complex<r_8> > const& fftx,r_8& A,r_8& B);
51 virtual r_8 TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx,r_8& A,r_8& B);
52 virtual r_8 TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx,r_8& A,r_8& B);
[710]53
[2526]54 virtual inline r_8 TransfEnergyFFT(TVector<r_4> const & x, TVector< complex<r_4> > const& fftx)
55 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
56 virtual inline r_8 TransfEnergyFFT(TVector<r_8> const & x, TVector< complex<r_8> > const& fftx)
57 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
58 virtual inline r_8 TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx)
59 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
60 virtual inline r_8 TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx)
61 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
[1630]62
[2526]63 //! Compute the size of the FFT vector given the input vector
64 virtual uint_4 SizeFFT(TVector<r_4> const & x) {return (uint_4) (x.Size()/2 + 1);}
65 virtual uint_4 SizeFFT(TVector<r_8> const & x) {return (uint_4) (x.Size()/2 + 1);}
66 virtual uint_4 SizeFFT(TVector< complex<r_4> > const & x) {return (uint_4) x.Size();}
67 virtual uint_4 SizeFFT(TVector< complex<r_8> > const & x) {return (uint_4) x.Size();}
[710]68
69 protected:
[1402]70
[710]71 bool _fgnorm;
72 string _info;
[1402]73
[710]74};
75
76
[1390]77template <class T>
78class FFTArrayChecker {
79public:
[1400]80 FFTArrayChecker(string msg, bool checkpack=true,
81 bool onedonly=false);
[1390]82 virtual ~FFTArrayChecker();
[1394]83 static T ZeroThreshold();
[1402]84
85 inline void SetMsg(string const & msg) { _msg = msg; }
86 inline void CheckPackedArray(bool ck=true) { _checkpack = ck; }
87 inline void Accept1DOnly(bool ac1d=false) { _onedonly = ac1d; }
88
[1390]89 virtual int CheckResize(TArray< complex<T> > const & in, TArray< complex<T> > & out);
90 virtual int CheckResize(TArray< T > const & in, TArray< complex<T> > & out);
[1402]91 virtual int CheckResize(TArray< complex<T> > const & in, TArray< T > & out,
92 bool usoutsz=false);
[1390]93
94protected:
[1394]95 string _msg;
[1390]96 bool _checkpack;
97 bool _onedonly;
[1402]98
[1390]99};
100
[1405]101} // Fin du namespace
102
[710]103#endif
Note: See TracBrowser for help on using the repository browser.