Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members  

derivative.h

Go to the documentation of this file.
00001 #ifndef __DERIVATIVE__
00002 #define __DERIVATIVE__
00003 
00049 namespace FFT{
00050 
00055   template <typename Complex_data_2D_array>
00056   void x_derivative(const Complex_data_2D_array& source,
00057                     Complex_data_2D_array* const result);
00058   
00063   template <typename Complex_data_2D_array>
00064   void y_derivative(const Complex_data_2D_array& source,
00065                     Complex_data_2D_array* const result);
00066 
00067 
00068 
00069 /*
00070   ###########################################################
00071   ###########################################################
00072   ###########################################################
00073   ##############                               ##############
00074   ##############  I M P L E M E N T A T I O N  ##############
00075   ##############                               ##############
00076   ###########################################################
00077   ###########################################################
00078   ###########################################################
00079 */
00080 
00081 
00082 
00083   
00084 
00085   template <typename Complex_data_2D_array>
00086   void x_derivative(const Complex_data_2D_array& source,
00087                     Complex_data_2D_array* const result){
00088 
00089     typedef typename Complex_data_2D_array::value_type complex_type;
00090     typedef float                                      real_type;
00091     typedef unsigned int                               size_type;
00092 
00093     const size_type width  = source.x_size();
00094     const size_type height = source.y_size();
00095     const size_type half_width  = width/2;
00096 
00097     if ((result->x_size()!=width)||(result->y_size()!=height)){
00098       result->resize(width,height);
00099     }
00100 
00101     for(size_type x=0;x<width;x++){
00102       for(size_type y=0;y<height;y++){
00103 
00104         const real_type X = static_cast<real_type>(x) -
00105           width*((x+half_width)/width);
00106        
00107         (*result)(x,y) = complex_type(0,2*M_PI*X/width)*source(x,y);
00108       }
00109     }
00110 
00111   }
00112 
00113 
00114   template <typename Complex_data_2D_array>
00115   void y_derivative(const Complex_data_2D_array& source,
00116                     Complex_data_2D_array* const result){
00117 
00118     typedef typename Complex_data_2D_array::value_type complex_type;
00119     typedef float                                      real_type;
00120     typedef unsigned int                               size_type;
00121 
00122     const size_type width  = source.x_size();
00123     const size_type height = source.y_size();
00124     const size_type half_width  = width/2;
00125 
00126     if ((result->x_size()!=width)||(result->y_size()!=height)){
00127       result->resize(width,height);
00128     }
00129 
00130     for(size_type x=0;x<width;x++){
00131       for(size_type y=0;y<height;y++){
00132       
00133         const real_type Y = static_cast<real_type>(y);
00134  
00135         (*result)(x,y) = complex_type(0,2*M_PI*Y/height)*source(x,y);
00136       }
00137     }
00138 
00139   }
00140 
00141 }
00142 
00143 #endif

Generated on Thu Aug 19 15:55:51 2004 by doxygen1.2.18