00001
00045 #ifndef __FFT_FILL__
00046 #define __FFT_FILL__
00047
00048
00049 namespace FFT{
00050
00053 template <typename Function,typename Complex_data_2D_array>
00054 void fill_real_part(const Function& f,
00055 Complex_data_2D_array* const array);
00056
00059 template <typename Function,typename Complex_data_2D_array>
00060 void fill_imaginary_part(const Function& f,
00061 Complex_data_2D_array* const array);
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00087 template <typename Function,typename Complex_data_2D_array>
00088 void fill_real_part(const Function& f,
00089 Complex_data_2D_array* const array){
00090
00091 typedef typename Complex_data_2D_array::value_type complex_type;
00092 typedef float real_type;
00093 typedef unsigned int size_type;
00094
00095 const size_type width = array->x_size();
00096 const size_type height = array->y_size();
00097
00098 const size_type half_width = width/2;
00099
00100 for(size_type x=0;x<width;x++){
00101 for(size_type y=0;y<height;y++){
00102
00103 const real_type X = static_cast<real_type>(x) -
00104 width*((x+half_width)/width);
00105
00106 const real_type Y = static_cast<real_type>(y);
00107
00108 (*array)(x,y) = complex_type(f(X,Y),(*array)(x,y).imag());
00109 }
00110 }
00111 }
00112
00113
00114
00121 template <typename Function,typename Complex_data_2D_array>
00122 void fill_imaginary_part(const Function& f,
00123 Complex_data_2D_array* const array){
00124
00125 typedef typename Complex_data_2D_array::value_type complex_type;
00126 typedef float real_type;
00127 typedef unsigned int size_type;
00128
00129 const size_type width = array->x_size();
00130 const size_type height = array->y_size();
00131
00132 const size_type half_width = width/2;
00133
00134 for(size_type x=0;x<width;x++){
00135 for(size_type y=0;y<height;y++){
00136
00137 const real_type X = static_cast<real_type>(x) -
00138 width*((x+half_width)/width);
00139
00140 const real_type Y = static_cast<real_type>(y) - 0.5*height;
00141
00142 (*array)(x,y) = complex_type((*array)(x,y).real(),f(X,Y));
00143 }
00144 }
00145 }
00146
00147 }
00148
00149 #endif