#ifndef glas_scalar_vector_mult_hpp #define glas_scalar_vector_mult_hpp #include #include #include namespace glas { template class scalar_vector_mult_expression { typedef typename value::type scalar_type ; // S can also be a scalar-expression instead of a builtin-type typedef typename value::type vvt ; public: static const int rank = 1 ; // required by Expression typedef typename mult_functor::result_type value_type ; // required by VectorExpression typedef typename V::size_type size_type ; // required by VectorExpression public: scalar_vector_mult_expression(S const & s, V const & v) : s_( s ), v_( v ) {} scalar_vector_mult_expression(scalar_vector_mult_expression const & v) : s_( v.s_ ), v_( v.v_ ) {} /// required by VectorExpression size_type size() const { return v_.size() ; } /// required by VectorExpression value_type operator[](size_type i) const { return s_ * v_[i] ; } /// required by VectorExpression value_type operator()(size_type i) const { return s_ * v_[i] ; } S const & arg1() const // FIRST_ARGUMENT in concept { return s_ ; } V const & arg2() const // SEDOND_ARGUMENT in concept { return v_ ; } private: // prohibit assignment void operator=(scalar_vector_mult_expression const &) ; private: scalar_type const & s_ ; V const & v_ ; } ; template scalar_vector_mult_expression scalar_vector_mult(S const & s, V const & v) { return scalar_vector_mult_expression(s,v) ; } template struct concept< scalar_vector_mult_expression > : concept< V > {} ; } #endif // glas_scalar_vector_mult_hpp