Changeset 1405 in Sophya for trunk/SophyaLib/NTools
- Timestamp:
- Feb 15, 2001, 6:58:16 PM (25 years ago)
- Location:
- trunk/SophyaLib/NTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/fftpserver.cc
r1402 r1405 15 15 necessarily correspond with the equivalent fftpack function. For example, 16 16 fftpack "forward" transformations are in fact inverse fourier transformations. 17 Otherwise, the output is in the fftpack format.18 19 17 20 18 Due to the way that fftpack manages … … 23 21 of differing length, it may be more efficient to create an fftserver object 24 22 for each length. 23 24 \code 25 #include "fftpserver.h" 26 // ... 27 TVector<r_8> in(32); 28 TVector< complex<r_8> > out; 29 in = RandomSequence(); 30 FFTPackServer ffts; 31 ffts.setNormalize(true); // To have normalized transforms 32 cout << " FFTServer info string= " << ffts.getInfo() << endl; 33 cout << "in= " << in << endl; 34 cout << " Calling ffts.FFTForward(in, out) : " << endl; 35 ffts.FFTForward(in, out); 36 cout << "out= " << out << endl; 37 \endcode 25 38 */ 26 39 -
trunk/SophyaLib/NTools/fftservintf.cc
r1402 r1405 6 6 \ingroup NTools 7 7 Defines the interface for FFT (Fast Fourier Transform) operations. 8 Definitions : 9 - Sampling period \b T 10 - Sampling frequency \b fs=1/T 11 - Total number of samples \b N 12 - Frequency step in Fourier space \b =fs/N=1/(N*T) 13 - Component frequencies 14 - k=0 -> 0 15 - k=1 -> 1/(N*T) 16 - k -> k/(N*T) 17 - k=N/2 -> 1/(2*T) (Nyquist frequency) 18 - k>N/2 -> k/(N*T) (or negative frequency -(N-k)/(N*T)) 19 20 For a sampling period T=1, the computed Fourier components correspond to : 21 \verbatim 22 0 1/N 2/N ... 1/2 1/2+1/N 1/2+2/N ... 1-2/N 1-1/N 23 0 1/N 2/N ... 1/2 ... -2/N -1/N 24 \endverbatim 25 26 For complex one-dimensional transforms: 27 \f[ 28 out(i) = F_{norm} \Sigma_{j} \ e^{-2 \pi \sqrt{-1} \ i \ j} \ {\rm (forward)} 29 \f] 30 \f[ 31 out(i) = F_{norm} \Sigma_{j} \ e^{2 \pi \sqrt{-1} \ i \ j} \ {\rm (backward)} 32 \f] 33 i,j= 0..N-1 , where N is the input or the output array size. 34 35 For complex multi-dimensional transforms: 36 \f[ 37 out(i1,i2,...,id) = F_{norm} \Sigma_{j1} \Sigma_{j2} ... \Sigma_{jd} \ 38 e^{-2 \pi \sqrt{-1} \ i1 \ j1} ... e^{-2 \pi \sqrt{-1} \ id \ jd} \ {\rm (forward)} 39 \f] 40 \f[ 41 out(i1,i2,...,id) = F_{norm} \Sigma_{j1} \Sigma_{j2} ... \Sigma_{jd} \ 42 e^{2 \pi \sqrt{-1} \ i1 \ j1} ... e^{2 \pi \sqrt{-1} \ id \ jd} \ {\rm (backward)} 43 \f] 44 45 For real forward transforms, the input array is real, and 46 the output array complex, with Fourier components up to k=N/2. 47 For real backward transforms, the input array is complex and 48 the output array is real. 8 49 */ 9 50 … … 23 64 24 65 /* --Methode-- */ 66 //! Forward Fourier transform for double precision complex data 67 /*! 68 \param in : Input complex array 69 \param out : Output complex array 70 */ 25 71 void FFTServerInterface::FFTForward(TArray< complex<r_8> > const &, TArray< complex<r_8> > &) 26 72 { … … 29 75 30 76 /* --Methode-- */ 77 //! Backward (inverse) Fourier transform for double precision complex data 78 /*! 79 \param in : Input complex array 80 \param out : Output complex array 81 */ 31 82 void FFTServerInterface::FFTBackward(TArray< complex<r_8> > const &, TArray< complex<r_8> > &) 32 83 { … … 35 86 36 87 /* --Methode-- */ 88 //! Forward Fourier transform for double precision real input data 89 /*! 90 \param in : Input real array 91 \param out : Output complex array 92 */ 37 93 void FFTServerInterface::FFTForward(TArray< r_8 > const &, TArray< complex<r_8> > &) 38 94 { … … 41 97 42 98 /* --Methode-- */ 99 //! Backward (inverse) Fourier transform for double precision real output data 100 /*! 101 \param in : Input complex array 102 \param out : Output real array 103 \param usoutsz : if true, use the output array size for computing the inverse FFT. 104 */ 43 105 void FFTServerInterface::FFTBackward(TArray< complex<r_8> > const &, TArray< r_8 > &, bool) 44 106 { … … 50 112 51 113 /* --Methode-- */ 114 //! Forward Fourier transform for complex data 115 /*! 116 \param in : Input complex array 117 \param out : Output complex array 118 */ 52 119 void FFTServerInterface::FFTForward(TArray< complex<r_4> > const &, TArray< complex<r_4> > &) 53 120 { … … 56 123 57 124 /* --Methode-- */ 125 //! Backward (inverse) Fourier transform for complex data 126 /*! 127 \param in : Input complex array 128 \param out : Output complex array 129 */ 58 130 void FFTServerInterface::FFTBackward(TArray< complex<r_4> > const &, TArray< complex<r_4> > &) 59 131 { … … 62 134 63 135 /* --Methode-- */ 136 //! Forward Fourier transform for real input data 137 /*! 138 \param in : Input real array 139 \param out : Output complex array 140 */ 64 141 void FFTServerInterface::FFTForward(TArray< r_4 > const &, TArray< complex<r_4> > &) 65 142 { … … 68 145 69 146 /* --Methode-- */ 147 //! Backward (inverse) Fourier transform for real output data 148 /*! 149 \param in : Input complex array 150 \param out : Output real array 151 \param usoutsz : if true, use the output array size for computing the inverse FFT. 152 */ 70 153 void FFTServerInterface::FFTBackward(TArray< complex<r_4> > const &, TArray< r_4 > &, bool) 71 154 { … … 76 159 77 160 /* --Methode-- */ 161 /*! 162 \class SOPHYA::FFTArrayChecker 163 \ingroup NTools 164 Service class for checking array size and resizing output arrays, 165 to be used by FFTServer classes 166 */ 167 78 168 template <class T> 79 169 FFTArrayChecker<T>::FFTArrayChecker(string msg, bool checkpack, bool onedonly) -
trunk/SophyaLib/NTools/fftservintf.h
r1402 r1405 27 27 virtual FFTServerInterface * Clone() = 0; 28 28 29 //! Set/clear the flag for normalizing Fourier transforms. 29 30 inline void setNormalize(bool fg=false) { _fgnorm = fg; } 31 //! Returns the status of normalization flag for the server 30 32 inline bool getNormalize() const { return(_fgnorm); } 33 //! Returns the information string associated with the server 31 34 inline string getInfo() const { return _info; } 32 35 … … 53 56 }; 54 57 55 } // Fin du namespace56 58 57 59 template <class T> … … 79 81 }; 80 82 83 } // Fin du namespace 84 81 85 #endif
Note:
See TracChangeset
for help on using the changeset viewer.