45#ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_IMPL_VECTOR_EXPRESSIONS_H 
   46#define LASS_GUARDIAN_OF_INCLUSION_NUM_IMPL_VECTOR_EXPRESSIONS_H 
   61    enum { lvalue = 
true };
 
   62    typedef typename util::CallTraits<T>::TValue TValue;
 
   63    typedef typename util::CallTraits<T>::TParam TParam;
 
   64    typedef typename util::CallTraits<T>::TReference TReference;
 
   65    typedef typename util::CallTraits<T>::TConstReference TConstReference;
 
   68    VStorage(): storage_() {}
 
   69    VStorage(TSize iSize, TParam iInitialValue): storage_(iSize, iInitialValue) {}
 
   70    TReference operator[](TSize iIndex) { LASS_ASSERT(iIndex < size()); 
return storage_[iIndex]; }
 
   71    TConstReference operator[](TSize iIndex)
 const { LASS_ASSERT(iIndex < size()); 
return storage_[iIndex]; }
 
   72    TSize size()
 const { 
return storage_.size(); }
 
   76    void resize(TSize iSize) { storage_.resize(iSize, T()); }
 
   77    void swap(VStorage<T>& iOther) { storage_.swap(iOther.storage_); }
 
   79    std::vector<T> storage_;
 
   88    enum { lvalue = 
false };
 
   89    typedef typename util::CallTraits<T>::TValue TValue;
 
   90    typedef typename util::CallTraits<T>::TParam TParam;
 
   93    VScalar(TSize iSize, TParam iValue): value_(iValue), size_(iSize) {}
 
   94    TParam operator[]([[maybe_unused]] TSize iIndex)
 const { LASS_ASSERT(iIndex < size_); 
return value_; }
 
   95    TSize size()
 const { 
return size_; }
 
  105template <
typename ExpressionType>
 
  106struct VectorExpressionTraits
 
  108    typedef const ExpressionType& TStorage;
 
  114struct VectorExpressionTraits<VScalar<T> >
 
  116    typedef VScalar<T> TStorage;
 
  123#define LASS_NUM_VECTOR_BINARY_EXPRESSION(i_name, c_operator)\ 
  124template <typename T, typename Operand1, typename Operand2>\ 
  125class LASS_CONCATENATE(V, i_name)\ 
  128    enum { lvalue = false };\ 
  129    typedef typename util::CallTraits<T>::TValue TValue;\ 
  130    typedef size_t TSize;\ 
  131    LASS_CONCATENATE(V, i_name)(const Operand1& iA, const Operand2& iB):\ 
  132        operand1_(iA), operand2_(iB)\ 
  134        LASS_ASSERT(operand1_.size() == operand2_.size());\ 
  136    TValue operator[](TSize iIndex) const { return operand1_[iIndex] c_operator operand2_[iIndex]; }\ 
  137    TSize size() const { return operand1_.size(); }\ 
  139    typename VectorExpressionTraits<Operand1>::TStorage operand1_;\ 
  140    typename VectorExpressionTraits<Operand2>::TStorage operand2_;\ 
  143LASS_NUM_VECTOR_BINARY_EXPRESSION(Add, +);
 
  144LASS_NUM_VECTOR_BINARY_EXPRESSION(Sub, -);
 
  145LASS_NUM_VECTOR_BINARY_EXPRESSION(Mul, *);
 
  146LASS_NUM_VECTOR_BINARY_EXPRESSION(Div, /);
 
  152#define LASS_NUM_VECTOR_UNARY_EXPRESSION(i_name, c_operator)\ 
  153template <typename T, typename Operand1>\ 
  154class LASS_CONCATENATE(V, i_name)\ 
  157    enum { lvalue = false };\ 
  158    typedef typename util::CallTraits<T>::TValue TValue;\ 
  159    typedef size_t TSize;\ 
  160    LASS_CONCATENATE(V, i_name)(const Operand1& iA): operand1_(iA) {}\ 
  161    TValue operator[](TSize iIndex) const { return c_operator operand1_[iIndex]; }\ 
  162    TSize size() const { return operand1_.size(); }\ 
  164    typename VectorExpressionTraits<Operand1>::TStorage operand1_;\ 
  167LASS_NUM_VECTOR_UNARY_EXPRESSION(Neg, -);
 
  168LASS_NUM_VECTOR_UNARY_EXPRESSION(Rec, ::lass::num::NumTraits<T>::one /);
 
  174template <
typename T, 
typename Operand1>
 
  178    enum { lvalue = 
false };
 
  179    typedef T (*TOperator)(T);
 
  180    typedef typename util::CallTraits<T>::TValue TValue;
 
  181    typedef size_t TSize;
 
  182    VFun(
const Operand1& iA, TOperator iOperator): operand1_(iA), operator_(iOperator) {}
 
  183    TValue operator[](TSize iIndex)
 const { 
return operator_(operand1_[iIndex]); }
 
  184    TSize size()
 const { 
return operand1_.size(); }
 
  186    typename VectorExpressionTraits<Operand1>::TStorage operand1_;
 
numeric types and traits.
 
Library for Assembled Shared Sources.