00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_MAT_MAT_OP_EXPR_INCLUDE
00013 #define MTL_MAT_MAT_OP_EXPR_INCLUDE
00014
00015 #include <boost/numeric/mtl/matrix/mat_expr.hpp>
00016 #include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp>
00017
00018 namespace mtl { namespace matrix {
00019
00020
00021 template <typename E1, typename E2, typename SFunctor>
00022 struct mat_mat_op_expr
00023 : public const_crtp_matrix_bracket< mat_mat_op_expr<E1, E2, SFunctor>,
00024 typename SFunctor::result_type,
00025 typename E1::size_type >
00026
00027 {
00028
00029 typedef mat_mat_op_expr self;
00030
00031 typedef typename SFunctor::result_type value_type;
00032
00033
00034 typedef typename E1::size_type size_type;
00035
00036 typedef value_type const_dereference_type ;
00037
00038 typedef E1 first_argument_type ;
00039 typedef E2 second_argument_type ;
00040
00041 mat_mat_op_expr( first_argument_type const& v1, second_argument_type const& v2 )
00042 :
00043 first( v1 ), second( v2 )
00044 {
00045 #if 0
00046 first.delay_assign();
00047 second.delay_assign();
00048 #endif
00049 }
00050
00051 void delay_assign() const {}
00052
00053 void check_shape() const {}
00054
00055 const_dereference_type operator() (size_type row, size_type col) const
00056 {
00057 return SFunctor::apply( first(row, col), second(row, col) ) ;
00058
00059 }
00060
00061 #if 0
00062 template <typename> friend size_type size(const self&);
00063 template <typename> friend size_type num_rows(const self&);
00064 template <typename> friend size_type num_cols(const self&);
00065 #endif
00066
00067 first_argument_type const& first ;
00068 second_argument_type const& second ;
00069 };
00070
00071
00072 template <typename E1, typename E2, typename SFunctor>
00073 typename mat_mat_op_expr<E1, E2, SFunctor>::size_type
00074 inline size(mat_mat_op_expr<E1, E2, SFunctor> const& expr)
00075 {
00076 expr.check_shape();
00077 return size(expr.first) ;
00078 }
00079
00080 template <typename E1, typename E2, typename SFunctor>
00081 typename mat_mat_op_expr<E1, E2, SFunctor>::size_type
00082 inline num_rows(mat_mat_op_expr<E1, E2, SFunctor> const& expr)
00083 {
00084 expr.check_shape();
00085 return num_rows(expr.first) ;
00086 }
00087
00088 template <typename E1, typename E2, typename SFunctor>
00089 typename mat_mat_op_expr<E1, E2, SFunctor>::size_type
00090 inline num_cols(mat_mat_op_expr<E1, E2, SFunctor> const& expr)
00091 {
00092 expr.check_shape();
00093 return num_cols(expr.first) ;
00094 }
00095
00096
00097 }}
00098
00099 #endif // MTL_MAT_MAT_OP_EXPR_INCLUDE