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

Last change on this file since 2308 was 1630, checked in by cmv, 24 years ago

routines de normalisation des fft cmv 8/8/01

File size: 4.3 KB
Line 
1// FFT (Fast Fourier Transform) Server Interface
2// R. Ansari 1999-2000
3// DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
4
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
29//! Set/clear the flag for normalizing Fourier transforms.
30 inline void setNormalize(bool fg=false) { _fgnorm = fg; }
31//! Returns the status of normalization flag for the server
32 inline bool getNormalize() const { return(_fgnorm); }
33//! Returns the information string associated with the server
34 inline string getInfo() const { return _info; }
35
36 //---------------------------------------------------
37 // Transforme N-dim sur des doubles
38 virtual void FFTForward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
39 virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray< complex<r_8> > & out);
40 virtual r_8 TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx
41 , r_8& A, r_8& B);
42 //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
43 virtual inline r_8 TransfEnergyFFT(TVector< complex<r_8> > const & x, TVector< complex<r_8> > const& fftx)
44 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
45
46 virtual void FFTForward(TArray< r_8 > const & in, TArray< complex<r_8> > & out);
47 virtual void FFTBackward(TArray< complex<r_8> > const & in, TArray< r_8 > & out,
48 bool usoutsz=false);
49 virtual r_8 TransfEnergyFFT(TVector< r_8 > const & x, TVector< complex<r_8> > const& fftx
50 , r_8& A, r_8& B);
51 //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
52 virtual inline r_8 TransfEnergyFFT(TVector< r_8 > const & x, TVector< complex<r_8> > const& fftx)
53 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
54
55 // Transforme N-dim sur des float
56 virtual void FFTForward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
57 virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out);
58 virtual r_8 TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx
59 , r_8& A, r_8& B);
60 //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
61 virtual inline r_8 TransfEnergyFFT(TVector< complex<r_4> > const & x, TVector< complex<r_4> > const& fftx)
62 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
63
64 virtual void FFTForward(TArray< r_4 > const & in, TArray< complex<r_4> > & out);
65 virtual void FFTBackward(TArray< complex<r_4> > const & in, TArray< r_4 > & out,
66 bool usoutsz=false);
67 virtual r_8 TransfEnergyFFT(TVector< r_4 > const & x, TVector< complex<r_4> > const& fftx
68 , r_8& A, r_8& B);
69 //! Compute the factor to be applied to "fftx=FFT(x)" so that "x" and "FFT(x)" have the same energy
70 virtual inline r_8 TransfEnergyFFT(TVector< r_4 > const & x, TVector< complex<r_4> > const& fftx)
71 {r_8 A,B; return TransfEnergyFFT(x,fftx,A,B);}
72
73 protected:
74
75 bool _fgnorm;
76 string _info;
77
78};
79
80
81template <class T>
82class FFTArrayChecker {
83public:
84 FFTArrayChecker(string msg, bool checkpack=true,
85 bool onedonly=false);
86 virtual ~FFTArrayChecker();
87 static T ZeroThreshold();
88
89 inline void SetMsg(string const & msg) { _msg = msg; }
90 inline void CheckPackedArray(bool ck=true) { _checkpack = ck; }
91 inline void Accept1DOnly(bool ac1d=false) { _onedonly = ac1d; }
92
93 virtual int CheckResize(TArray< complex<T> > const & in, TArray< complex<T> > & out);
94 virtual int CheckResize(TArray< T > const & in, TArray< complex<T> > & out);
95 virtual int CheckResize(TArray< complex<T> > const & in, TArray< T > & out,
96 bool usoutsz=false);
97
98protected:
99 string _msg;
100 bool _checkpack;
101 bool _onedonly;
102
103};
104
105} // Fin du namespace
106
107#endif
Note: See TracBrowser for help on using the repository browser.