matop_macros.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00037 #ifndef matop_macros_h
00038 #define matop_macros_h
00039 
00041 #define CML_MAT_UNIOP(_op_, _OpT_)                                       \
00042 template<typename E, class AT, typename BO, typename L>                  \
00043 inline et::MatrixXpr<                                                    \
00044     et::UnaryMatrixOp< matrix<E,AT,BO,L>, _OpT_ <E> >                    \
00045 >                                                                        \
00046                                                                          \
00047 _op_ (const matrix<E,AT,BO,L>& arg)                                      \
00048 {                                                                        \
00049     typedef et::UnaryMatrixOp<                                           \
00050             matrix<E,AT,BO,L>, _OpT_ <E>                                 \
00051         > ExprT;                                                         \
00052     return et::MatrixXpr<ExprT>(ExprT(arg));                             \
00053 }
00054 
00056 #define CML_MATXPR_UNIOP(_op_, _OpT_)                                    \
00057 template<class XprT>                                                     \
00058 inline et::MatrixXpr<                                                    \
00059     et::UnaryMatrixOp<XprT, _OpT_<typename XprT::value_type> >           \
00060 >                                                                        \
00061                                                                          \
00062 _op_ (MATXPR_ARG_TYPE arg)                                               \
00063 {                                                                        \
00064     typedef et::UnaryMatrixOp<                                           \
00065         XprT, _OpT_<typename XprT::value_type>                           \
00066         > ExprT;                                                         \
00067     return et::MatrixXpr<ExprT>(ExprT(arg.expression()));                \
00068 }
00069 
00071 #define CML_MAT_MAT_BINOP(_op_, _OpT_)                                   \
00072 template<typename E1, class AT1, typename L1,                            \
00073          typename E2, class AT2, typename L2, typename BO>               \
00074 inline et::MatrixXpr<                                                    \
00075     et::BinaryMatrixOp<                                                  \
00076         matrix<E1,AT1,BO,L2>, matrix<E2,AT2,BO,L2>, _OpT_<E1,E2> >       \
00077 >                                                                        \
00078                                                                          \
00079 _op_ (                                                                   \
00080         const matrix<E1,AT1,BO,L1>& left,                                \
00081         const matrix<E2,AT2,BO,L2>& right)                               \
00082 {                                                                        \
00083     typedef et::BinaryMatrixOp<                                          \
00084             matrix<E1,AT1,BO,L1>, matrix<E2,AT2,BO,L2>, _OpT_<E1,E2>     \
00085         > ExprT;                                                         \
00086     return et::MatrixXpr<ExprT>(ExprT(left,right));                      \
00087 }
00088 
00090 #define CML_MAT_MATXPR_BINOP(_op_, _OpT_)                                \
00091 template<typename E, class AT, typename BO, typename L, class XprT>      \
00092 inline et::MatrixXpr<                                                    \
00093     et::BinaryMatrixOp<                                                  \
00094         matrix<E,AT,BO,L>, XprT, _OpT_ <E, typename XprT::value_type>    \
00095     >                                                                    \
00096 >                                                                        \
00097                                                                          \
00098 _op_ (                                                                   \
00099         const matrix<E,AT,BO,L>& left,                                   \
00100         MATXPR_ARG_TYPE right)                                           \
00101 {                                                                        \
00102     typedef et::BinaryMatrixOp<                                          \
00103             matrix<E,AT,BO,L>, XprT,                                     \
00104             _OpT_ <E, typename XprT::value_type>                         \
00105         > ExprT;                                                         \
00106     return et::MatrixXpr<ExprT>(ExprT(left,right.expression()));         \
00107 }
00108 
00110 #define CML_MATXPR_MAT_BINOP(_op_, _OpT_)                                \
00111 template<class XprT, typename E, class AT, typename BO, typename L>      \
00112 inline et::MatrixXpr<                                                    \
00113     et::BinaryMatrixOp<                                                  \
00114         XprT, matrix<E,AT,BO,L>, _OpT_ <typename XprT::value_type, E>    \
00115     >                                                                    \
00116 >                                                                        \
00117                                                                          \
00118 _op_ (                                                                   \
00119         MATXPR_ARG_TYPE left,                                            \
00120         const matrix<E,AT,BO,L>& right)                                  \
00121 {                                                                        \
00122     typedef et::BinaryMatrixOp<                                          \
00123             XprT, matrix<E,AT,BO,L>,                                     \
00124             _OpT_ <typename XprT::value_type, E>                         \
00125         > ExprT;                                                         \
00126     return et::MatrixXpr<ExprT>(ExprT(left.expression(),right));         \
00127 }
00128 
00130 #define CML_MATXPR_MATXPR_BINOP(_op_, _OpT_)                             \
00131 template<class XprT1, class XprT2>                                       \
00132 inline et::MatrixXpr<                                                    \
00133     et::BinaryMatrixOp<                                                  \
00134         XprT1, XprT2,                                                    \
00135         _OpT_ <                                                          \
00136             typename XprT1::value_type,                                  \
00137             typename XprT2::value_type                                   \
00138         >                                                                \
00139     >                                                                    \
00140 >                                                                        \
00141                                                                          \
00142 _op_ (                                                                   \
00143         MATXPR_ARG_TYPE_N(1) left,                                       \
00144         MATXPR_ARG_TYPE_N(2) right)                                      \
00145 {                                                                        \
00146     typedef et::BinaryMatrixOp<                                          \
00147             XprT1, XprT2,                                                \
00148             _OpT_ <                                                      \
00149                 typename XprT1::value_type,                              \
00150                 typename XprT2::value_type>                              \
00151         > ExprT;                                                         \
00152     return et::MatrixXpr<ExprT>(                                         \
00153             ExprT(left.expression(),right.expression()));                \
00154 }
00155 
00156 
00158 #define CML_MAT_SCALAR_BINOP(_op_, _OpT_)                                \
00159 template<typename E, class AT, typename BO, typename L, typename ScalarT>\
00160 inline et::MatrixXpr<                                                    \
00161     et::BinaryMatrixOp<                                                  \
00162         matrix<E,AT,BO,L>, ScalarT, _OpT_ <E,ScalarT>                    \
00163     >                                                                    \
00164 >                                                                        \
00165                                                                          \
00166 _op_ (                                                                   \
00167         const matrix<E,AT,BO,L>& left,                                   \
00168         SCALAR_ARG_TYPE right)                                           \
00169 {                                                                        \
00170     typedef et::BinaryMatrixOp<                                          \
00171             matrix<E,AT,BO,L>, ScalarT, _OpT_ <E,ScalarT  >              \
00172         > ExprT;                                                         \
00173     return et::MatrixXpr<ExprT>(ExprT(left,right));                      \
00174 }
00175 
00177 #define CML_SCALAR_MAT_BINOP(_op_, _OpT_)                                \
00178 template<typename ScalarT, typename E, class AT, typename BO, typename L>\
00179 inline et::MatrixXpr<                                                    \
00180     et::BinaryMatrixOp<                                                  \
00181         ScalarT, matrix<E,AT,BO,L>, _OpT_ <ScalarT,E>                    \
00182     >                                                                    \
00183 >                                                                        \
00184                                                                          \
00185 _op_ (                                                                   \
00186         SCALAR_ARG_TYPE left,                                            \
00187         const matrix<E,AT,BO,L>& right)                                  \
00188 {                                                                        \
00189     typedef et::BinaryMatrixOp<                                          \
00190             ScalarT, matrix<E,AT,BO,L>, _OpT_<ScalarT,E>                 \
00191         > ExprT;                                                         \
00192     return et::MatrixXpr<ExprT>(ExprT(left,right));                      \
00193 }
00194 
00196 #define CML_MATXPR_SCALAR_BINOP(_op_, _OpT_)                             \
00197 template<class XprT, typename ScalarT>                                   \
00198 inline et::MatrixXpr<                                                    \
00199     et::BinaryMatrixOp<                                                  \
00200         XprT, ScalarT, _OpT_ <typename XprT::value_type, ScalarT>        \
00201     >                                                                    \
00202 >                                                                        \
00203                                                                          \
00204 _op_ (                                                                   \
00205         MATXPR_ARG_TYPE left,                                            \
00206         SCALAR_ARG_TYPE right)                                           \
00207 {                                                                        \
00208     typedef et::BinaryMatrixOp<                                          \
00209             XprT, ScalarT, _OpT_ <typename XprT::value_type,ScalarT>     \
00210         > ExprT;                                                         \
00211     return et::MatrixXpr<ExprT>(ExprT(left.expression(),right));         \
00212 }
00213 
00215 #define CML_SCALAR_MATXPR_BINOP(_op_, _OpT_)                             \
00216 template<typename ScalarT, class XprT>                                   \
00217 inline et::MatrixXpr<                                                    \
00218     et::BinaryMatrixOp<                                                  \
00219         ScalarT, XprT, _OpT_ <ScalarT, typename XprT::value_type>        \
00220     >                                                                    \
00221 >                                                                        \
00222                                                                          \
00223 _op_ (                                                                   \
00224         SCALAR_ARG_TYPE left,                                            \
00225         MATXPR_ARG_TYPE right)                                           \
00226 {                                                                        \
00227     typedef et::BinaryMatrixOp<                                          \
00228             ScalarT, XprT, _OpT_ <ScalarT, typename XprT::value_type>    \
00229         > ExprT;                                                         \
00230     return et::MatrixXpr<ExprT>(ExprT(left,right.expression()));         \
00231 }
00232 
00233 #endif
00234 
00235 // -------------------------------------------------------------------------
00236 // vim:ft=cpp

Generated on Sat Jul 18 19:35:23 2009 for CML 1.0 by  doxygen 1.5.9