00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE
00013 #define MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE
00014
00015 #include <boost/numeric/mtl/vector/vec_expr.hpp>
00016 #include <boost/numeric/mtl/operation/compute_summand.hpp>
00017
00018 namespace mtl { namespace vector {
00019
00020
00021 template <class E1, class E2, typename SFunctor>
00022 struct vec_vec_pmop_expr
00023 : vec_expr< vec_vec_pmop_expr<E1, E2, SFunctor> >
00024 {
00025 typedef vec_vec_pmop_expr<E1, E2, SFunctor> self;
00026 typedef typename mtl::operation::compute_summand<E1>::type first_argument_type;
00027 typedef typename mtl::operation::compute_summand<E2>::type second_argument_type;
00028 typedef SFunctor functor_type;
00029
00030 typedef typename SFunctor::result_type const_dereference_type;
00031
00032 typedef const_dereference_type value_type;
00033 typedef typename first_argument_type::size_type size_type;
00034
00035 vec_vec_pmop_expr( E1 const& v1, E2 const& v2 )
00036 : first(v1), second(v2)
00037 {
00038 first.value.delay_assign(); second.value.delay_assign();
00039 }
00040
00041 void delay_assign() const {}
00042
00043 friend size_type inline size(const self& x)
00044 {
00045 assert( size(x.first.value) == 0 || size(x.first.value) == size(x.second.value) );
00046 return size(x.first.value);
00047 }
00048
00049 #if 0
00050 size_type size() const
00051 {
00052
00053 assert( first.value.size() == second.value.size() ) ;
00054 return first.value.size() ;
00055 }
00056 #endif
00057
00058 const_dereference_type operator() (size_type i) const
00059 {
00060 return SFunctor::apply(first.value(i), second.value(i));
00061 }
00062
00063 const_dereference_type operator[] (size_type i) const
00064 {
00065 return SFunctor::apply(first.value(i), second.value(i));
00066 }
00067
00068 private:
00069 operation::compute_summand<E1> first;
00070 operation::compute_summand<E2> second;
00071 };
00072
00073
00074 }}
00075
00076 #endif // MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE