SkelGIS  3.0
/home/helene/Documents/These/SkelGIS/SkelGIS_Library/SkelGIS_V3/skelgis/skeletons/basic_skeletons/DMatrix/apply_unary.hpp
Go to the documentation of this file.
00001 /*! \file apply_unary.hpp
00002  *  \brief Definitions of the skeleton object ApplyUnary. This skeleton takes a user function and a DMatrix as inputs and return a new DMatrix as output.
00003  */
00004 #ifndef APPLY_UNARY_H
00005 #define APPLY_UNARY_H
00006 
00007 namespace skelgis{
00008 
00009   //================================================================================
00010   //Types of user functions
00011   //================================================================================
00012   //! _ApplyUnary_Func structure
00013   /*!
00014     These objects are not directly used by the user, but the macros used by the user, to define its functions, use these. Four specializations of this structure are available.
00015     \tparam T is the type of data to store in the input DMatrix
00016     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00017     \tparam T2 is the type of data to store in the output DMatrix
00018     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00019     \tparam line is the parallel distribution wanted, the default value is true, then the parallel distribution will be divided along height but not along width
00020   */
00021   //-------------------------------------------------------------------------------
00022   template <typename T,int R, typename T2,int R2,bool line=true> struct _ApplyUnary_Func
00023   //-------------------------------------------------------------------------------
00024   {
00025     virtual void operator()(DMatrix <T,R>&, DMatrix<T2,R2>&) const =0;
00026   };
00027   //================================================================================
00028   //! _ApplyUnary_Func structure
00029   /*!
00030     \tparam T is the type of data to store in the input DMatrix
00031     R overlap template parameter is not asked and specialized to 0
00032     \tparam T2 is the type of data to store in the output DMatrix
00033     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00034     The default value of line is used (true)
00035   */
00036   //-------------------------------------------------------------------------------
00037   template <typename T, typename T2,int R2> struct _ApplyUnary_Func<T,0,T2,R2>
00038   //-------------------------------------------------------------------------------
00039   {
00040     virtual void operator()(DMatrix<T,0>&, DMatrix<T2,R2>&) const =0;
00041   };
00042   //================================================================================
00043   //! _ApplyUnary_Func structure
00044   /*!
00045     \tparam T is the type of data to store in the input DMatrix
00046     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00047     \tparam T2 is the type of data to store in the output DMatrix
00048     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00049     The line template parameter is specialized with the false value. In this case the parallel data distribution will be done along height and width (by block)
00050   */
00051   //-------------------------------------------------------------------------------
00052   template <typename T, int R, typename T2,int R2> struct _ApplyUnary_Func<T,R,T2,R2,false>
00053   //-------------------------------------------------------------------------------
00054   {
00055     virtual void operator()(DMatrix<T,R,false>&, DMatrix<T2,R2,false>&) const =0;
00056   };
00057   //================================================================================
00058   //! _ApplyUnary_Func structure
00059   /*!
00060     \tparam T is the type of data to store in the input DMatrix
00061     R overlap template parameter is not asked and specialized to 0
00062     \tparam T2 is the type of data to store in the output DMatrix
00063     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00064     The line template parameter is specialized with the false value. In this case the parallel data distribution will be done along height and width (by block)
00065   */
00066   //-------------------------------------------------------------------------------
00067   template <typename T, typename T2,int R2> struct _ApplyUnary_Func<T,0,T2,R2,false>
00068   //-------------------------------------------------------------------------------
00069   {
00070     virtual void operator()(DMatrix<T,0,false>&, DMatrix<T2,R2,false>&) const =0;
00071   };
00072   //-------------------------------------------------------------------------------
00073 
00074   //================================================================================
00075   //Specializations of skeleton ApplyUnary
00076   //================================================================================
00077   //! ApplyUnary structure
00078   /*!
00079     These objects are directly called by the user to apply a function on a DMatrix.
00080     \tparam T is the type of data to store in the input DMatrix
00081     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00082     \tparam T2 is the type of data to store in the output DMatrix
00083     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00084     \tparam line is the parallel distribution wanted, the default value is true, then the parallel distribution will be divided along height but not along width
00085     \tparam local is a particular choice if it is explicitely indicate to not make any MPI exchanges. The default behavior is to make normaly MPI exchanges.
00086   */
00087   //-------------------------------------------------------------------------------
00088   template<class T,int R,class T2,int R2,bool line=true,bool local=false> struct ApplyUnary{};
00089   //-------------------------------------------------------------------------------
00090 
00091   //================================================================================
00092   //! ApplyUnary structure
00093   /*!
00094     First specialization with line and local default values.
00095     \tparam T is the type of data to store in the input DMatrix
00096     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00097     \tparam T2 is the type of data to store in the output DMatrix
00098     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00099   */
00100   //-------------------------------------------------------------------------------
00101   template<class T,int R,class T2,int R2> struct ApplyUnary<T,R,T2,R2>
00102   //-------------------------------------------------------------------------------
00103   {
00104     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00105     /*inline static DMatrix<T2,R2> apply(const _ApplyUnary_Func<T,R,T2,R2>& func, DMatrix<T,R>& m)
00106     {
00107       DMatrix<T2,R2> m2(m.getGlobalHeader(),0);
00108       m.getBorders();
00109       func(m,m2);
00110       return m2;
00111       }*/
00112 
00113     static void apply(const _ApplyUnary_Func<T,R,T2,R2>& func, DMatrix<T,R>& m, DMatrix<T2,R2>& m2)
00114     {
00115       m.getBorders();
00116       func(m,m2);
00117     }
00118   };
00119   //-------------------------------------------------------------------------------
00120 
00121   //================================================================================
00122   //! ApplyUnary structure
00123   /*!
00124     Second specialization with line and local default values and R=0
00125     \tparam T is the type of data to store in the input DMatrix
00126     R overlap template parameter is not asked and specialized to 0
00127     \tparam T2 is the type of data to store in the output DMatrix
00128     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00129   */
00130   //-------------------------------------------------------------------------------
00131   template<class T,class T2,int R2> struct ApplyUnary<T,0,T2,R2>
00132   //-------------------------------------------------------------------------------
00133   {
00134     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00135     /*inline static DMatrix<T2,R2> apply(const _ApplyUnary_Func<T,0,T2,R2>& func, DMatrix<T,0>& m)
00136     {
00137       DMatrix<T2,R2> m2(m.getGlobalHeader(),0);
00138       func(m,m2);
00139       return m2;
00140       }*/
00141 
00142     inline static void apply(const _ApplyUnary_Func<T,0,T2,R2>& func, DMatrix<T,0>& m, DMatrix<T2,R2>& m2){func(m,m2);}
00143   };
00144   //-------------------------------------------------------------------------------
00145 
00146   //================================================================================
00147   //! ApplyUnary structure
00148   /*!
00149     Third specialization with line=true and local=true
00150     \tparam T is the type of data to store in the input DMatrix
00151     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00152     \tparam T2 is the type of data to store in the output DMatrix
00153     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00154   */
00155   //-------------------------------------------------------------------------------
00156   template<class T,int R,class T2,int R2> struct ApplyUnary<T,R,T2,R2,true,true>
00157   //-------------------------------------------------------------------------------
00158   {
00159     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00160     /*inline static DMatrix<T2,R2> apply(const _ApplyUnary_Func<T,R,T2,R2>& func, DMatrix<T,R>& m)
00161     {
00162       DMatrix<T2,R2> m2(m.getGlobalHeader(),0);
00163       func(m,m2);
00164       return m2;
00165       }*/
00166 
00167     inline static void apply(const _ApplyUnary_Func<T,R,T2,R2>& func, DMatrix<T,R>& m, DMatrix<T2,R2>& m2){func(m,m2);}
00168   };
00169   //-------------------------------------------------------------------------------
00170 
00171   //================================================================================
00172   //! ApplyUnary structure
00173   /*!
00174     Fourth specialization with line=true and local=true and R=0
00175     \tparam T is the type of data to store in the input DMatrix
00176     R overlap template parameter is not asked and specialized to 0
00177     \tparam T2 is the type of data to store in the output DMatrix
00178     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00179   */
00180   //-------------------------------------------------------------------------------
00181   template<class T,class T2,int R2> struct ApplyUnary<T,0,T2,R2,true,true>
00182   //-------------------------------------------------------------------------------
00183   {
00184     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00185     /*inline static DMatrix<T2,R2> apply(const _ApplyUnary_Func<T,0,T2,R2>& func, DMatrix<T,0>& m)
00186     {
00187       DMatrix<T2,R2> m2(m.getGlobalHeader(),0);
00188       func(m,m2);
00189       return m2;
00190       }*/
00191 
00192     inline static void apply(const _ApplyUnary_Func<T,0,T2,R2>& func, DMatrix<T,0>& m, DMatrix<T2,R2>& m2){func(m,m2);}
00193   };
00194   //-------------------------------------------------------------------------------
00195 
00196   //================================================================================
00197   //! ApplyUnary structure
00198   /*!
00199     Fith specialization with line=false and local=false default value
00200     \tparam T is the type of data to store in the input DMatrix
00201     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00202     \tparam T2 is the type of data to store in the output DMatrix
00203     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00204   */
00205   //-------------------------------------------------------------------------------
00206   template<class T,int R,class T2,int R2> struct ApplyUnary<T,R,T2,R2,false>
00207   //-------------------------------------------------------------------------------
00208   {
00209     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00210     /*inline static DMatrix<T2,R2,false> apply(const _ApplyUnary_Func<T,R,T2,R2,false>& func, DMatrix<T,R,false>& m)
00211     {
00212       DMatrix<T2,R2,false> m2(m.getGlobalHeader(),0);
00213       m.getBorders();
00214       func(m,m2);
00215       return m2;
00216       }*/
00217 
00218     static void apply(const _ApplyUnary_Func<T,R,T2,R2,false>& func, DMatrix<T,R,false>& m, DMatrix<T2,R2,false>& m2)
00219     {
00220       m.getBorders();
00221       func(m,m2);
00222     }
00223   };
00224   //-------------------------------------------------------------------------------
00225 
00226   //================================================================================
00227   //! ApplyUnary structure
00228   /*!
00229     Sixth specialization with line=false and local=false default value and R=0
00230     \tparam T is the type of data to store in the input DMatrix
00231     R overlap template parameter is not asked and specialized to 0
00232     \tparam T2 is the type of data to store in the output DMatrix
00233     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00234   */
00235   //-------------------------------------------------------------------------------
00236   template<class T,class T2,int R2> struct ApplyUnary<T,0,T2,R2,false>
00237   //-------------------------------------------------------------------------------
00238   {
00239     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00240     /*inline static DMatrix<T2,R2,false> apply(const _ApplyUnary_Func<T,0,T2,R2,false>& func, DMatrix<T,0,false>& m)
00241     {
00242       DMatrix<T2,R2,false> m2(m.getGlobalHeader(),0);
00243       func(m,m2);
00244       return m2;
00245       }*/
00246 
00247     inline static void apply(const _ApplyUnary_Func<T,0,T2,R2,false>& func, DMatrix<T,0,false>& m, DMatrix<T2,R2,false>& m2){func(m,m2);}
00248   };
00249   //-------------------------------------------------------------------------------
00250 
00251   //================================================================================
00252   //! ApplyUnary structure
00253   /*!
00254     Seventh specialization with line=false and local=true
00255     \tparam T is the type of data to store in the input DMatrix
00256     \tparam R is the overlap distance needed by the calculation for the input DMatrix.
00257     \tparam T2 is the type of data to store in the output DMatrix
00258     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00259   */
00260   //-------------------------------------------------------------------------------
00261   template<class T,int R,class T2,int R2> struct ApplyUnary<T,R,T2,R2,false,true>
00262   //-------------------------------------------------------------------------------
00263   {
00264     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00265     /*inline static DMatrix<T2,R2,false> apply(const _ApplyUnary_Func<T,R,T2,R2,false>& func, DMatrix<T,R,false>& m)
00266     {
00267       DMatrix<T2,R2,false> m2(m.getGlobalHeader(),0);
00268       func(m,m2);
00269       return m2;
00270       }*/
00271 
00272     inline static void apply(const _ApplyUnary_Func<T,R,T2,R2,false>& func, DMatrix<T,R,false>& m, DMatrix<T2,R2,false>& m2){func(m,m2);}
00273   };
00274   //-------------------------------------------------------------------------------
00275 
00276   //================================================================================
00277   //! ApplyUnary structure
00278   /*!
00279     Eighth specialization with line=false and local=true and R=0
00280     \tparam T is the type of data to store in the input DMatrix
00281     R overlap template parameter is not asked and specialized to 0
00282     \tparam T2 is the type of data to store in the output DMatrix
00283     \tparam R2 is the overlap distance needed by the calculation for the output DMatrix.
00284   */
00285   //-------------------------------------------------------------------------------
00286   template<class T,class T2,int R2> struct ApplyUnary<T,0,T2,R2,false,true>
00287   //-------------------------------------------------------------------------------
00288   {
00289     //need an operator=(DMatrixw<...> m) in dmatrix.hpp
00290     /*inline static DMatrix<T2,R2,false> apply(const _ApplyUnary_Func<T,0,T2,R2,false>& func, DMatrix<T,0,false>& m)
00291     {
00292       DMatrix<T2,R2,false> m2(m.getGlobalHeader(),0);
00293       func(m,m2);
00294       return m2;
00295       }*/
00296 
00297     inline static void apply(const _ApplyUnary_Func<T,0,T2,R2,false>& func, DMatrix<T,0,false>& m, DMatrix<T2,R2,false>& m2){func(m,m2);}
00298     };
00299   //-------------------------------------------------------------------------------
00300 
00301 }
00302 
00303 #endif
 All Classes Files Functions Variables Defines