00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef FFT_MANAGER_H
00032 #define FFT_MANAGER_H
00033
00034 #ifndef FFTW_REAL_TO_COMPLEX
00035 #define FFTW_REAL_TO_COMPLEX FFTW_FORWARD
00036 #define FFTW_COMPLEX_TO_REAL FFTW_BACKWARD
00037 #endif
00038
00039 #include <fftw3.h>
00040 #include <iostream>
00041 #include <vector>
00042 #include <string>
00043 #include "AO_cpp.h"
00044
00045
00046 namespace Arroyo {
00047
00048 using std::string;
00049 using std::vector;
00050 using std::ostream;
00051
00059
00060 template<class T>
00061 class fft_manager {
00062
00063 private:
00064
00065
00066 protected:
00067
00068
00069 public:
00070
00073 fft_manager();
00074
00077 fft_manager(const fft_manager<T> & fft_mgr);
00078
00081 ~fft_manager();
00082
00085 fft_manager<T> & operator=(const fft_manager<T> & fft_mgr);
00086
00093 void forward_fft(const vector<long> & in_array_dimens,
00094 bool estimate, bool in_place,
00095 T * in, T * out = NULL);
00096
00105 void forward_fft(const vector<long> & in_array_dimens,
00106 bool estimate, bool in_place,
00107 int howmany, T * in, int istride, int idist,
00108 T * out=NULL, int ostride=1, int odist=1);
00109
00116 void backward_fft(const vector<long> & in_array_dimens,
00117 bool estimate, bool in_place,
00118 T * in, T * out = NULL);
00119
00128 void backward_fft(const vector<long> & in_array_dimens,
00129 bool estimate, bool in_place,
00130 int howmany, T * in, int istride, int idist,
00131 T * out=NULL, int ostride=1, int odist=1);
00132
00134 static int verbose_level;
00135
00136 };
00137
00138 template<class T>
00139 int fft_manager<T>::verbose_level = 0;
00140
00141 template<class T>
00142 fft_manager<T>::fft_manager(const fft_manager<T> & fft_mgr){
00143
00144 this->operator=(fft_mgr);
00145 }
00146
00147 template<class T>
00148 fft_manager<T>::~fft_manager(){
00149 }
00150
00151 template<class T>
00152 fft_manager<T> & fft_manager<T>::operator=(const fft_manager<T> & fft_mgr){
00153 if(this==&fft_mgr)
00154 return(*this);
00155
00156 return(*this);
00157 }
00158
00159 template<class T>
00160 void fft_manager<T>::forward_fft(const vector<long> & in_array_dimens,
00161 bool estimate, bool in_place,
00162 T * in, T * out) {
00163 this->forward_fft(in_array_dimens, estimate, in_place, 1, in, 1, 1, out, 1, 1);
00164 }
00165
00166 template<class T>
00167 void fft_manager<T>::backward_fft(const vector<long> & in_array_dimens,
00168 bool estimate, bool in_place,
00169 T * in, T * out) {
00170 this->backward_fft(in_array_dimens, estimate, in_place, 1, in, 1, 1, out, 1, 1);
00171 }
00172
00173
00178
00179 template<class T>
00180 class rfft_manager {
00181
00182 private:
00183
00184
00185 protected:
00186
00187
00188 public:
00189
00192 rfft_manager();
00193
00196 rfft_manager(const rfft_manager<T> & rfft_mgr);
00197
00200 ~rfft_manager();
00201
00204 rfft_manager<T> & operator=(const rfft_manager<T> & rfft_mgr);
00205
00215 void real_to_complex_fft(const vector<long> & in_array_dimens,
00216 bool estimate, bool in_place,
00217 T * in, T * out = NULL) ;
00218
00227 void real_to_complex_fft(const vector<long> & in_array_dimens,
00228 bool estimate, bool in_place,
00229 int howmany, T * in, int istride, int idist,
00230 T * out=NULL, int ostride=1, int odist=1) ;
00231
00238 void complex_to_real_fft(const vector<long> & in_array_dimens,
00239 bool estimate, bool in_place,
00240 T * in, T * out = NULL) ;
00241
00250 void complex_to_real_fft(const vector<long> & in_array_dimens,
00251 bool estimate, bool in_place,
00252 int howmany, T * in, int istride, int idist,
00253 T * out=NULL, int ostride=1, int odist=1) ;
00254
00256 static int verbose_level;
00257
00258 };
00259
00260 template<class T>
00261 int rfft_manager<T>::verbose_level = 0;
00262
00263
00264 template<class T>
00265 rfft_manager<T>::rfft_manager(const rfft_manager<T> & rfft_mgr){
00266
00267 this->operator=(rfft_mgr);
00268 }
00269
00270 template<class T>
00271 rfft_manager<T>::~rfft_manager(){
00272
00273 }
00274
00275 template<class T>
00276 rfft_manager<T> & rfft_manager<T>::operator=(const rfft_manager<T> & rfft_mgr){
00277 if(this==&rfft_mgr)
00278 return(*this);
00279
00280 return(*this);
00281 }
00282
00283 template<class T>
00284 void rfft_manager<T>::real_to_complex_fft(
00285 const vector<long> & in_array_dimens,
00286 bool estimate, bool in_place,
00287 T * in, T * out) {
00288 this->real_to_complex_fft(in_array_dimens, estimate, in_place,
00289 1, in, 1, 1, out, 1, 1);
00290 }
00291
00292 template<class T>
00293 void rfft_manager<T>::complex_to_real_fft(
00294 const vector<long> & in_array_dimens,
00295 bool estimate, bool in_place,
00296 T * in, T * out) {
00297 this->complex_to_real_fft(in_array_dimens, estimate, in_place,
00298 1, in, 1, 1, out, 1, 1);
00299 }
00300
00301 }
00302
00303 #endif