#ifndef BZ_TINYVEC_CC #define BZ_TINYVEC_CC #ifndef BZ_TINYVEC_H #include #endif #ifndef BZ_VECTOR_H #include #endif #ifndef BZ_VECPICK_H #include #endif #ifndef BZ_RANGE_H #include #endif #include BZ_NAMESPACE(blitz) template inline TinyVector::TinyVector(T_numtype initValue) { for (int i=0; i < N_length; ++i) data_[i] = initValue; } template inline TinyVector::TinyVector(const TinyVector& x) { for (int i=0; i < N_length; ++i) data_[i] = x.data_[i]; } template template inline void TinyVector::_bz_assign(P_expr expr, P_updater up) { BZPRECHECK(expr.length(N_length) == N_length, "An expression with length " << expr.length(N_length) << " was assigned to a TinyVector<" << BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(T_numtype) << "," << N_length << ">"); if (expr._bz_hasFastAccess()) { _bz_meta_vecAssign::fastAssign(*this, expr, up); } else { _bz_meta_vecAssign::assign(*this, expr, up); } } /***************************************************************************** * Assignment operators with vector expression operand */ template template inline TinyVector& TinyVector::operator=(_bz_VecExpr expr) { _bz_assign(expr, _bz_update()); return *this; } template template inline TinyVector& TinyVector::operator+=(_bz_VecExpr expr) { _bz_assign(expr, _bz_plus_update()); return *this; } template template inline TinyVector& TinyVector::operator-=(_bz_VecExpr expr) { _bz_assign(expr, _bz_minus_update()); return *this; } template template inline TinyVector& TinyVector::operator*=(_bz_VecExpr expr) { _bz_assign(expr, _bz_multiply_update()); return *this; } template template inline TinyVector& TinyVector::operator/=(_bz_VecExpr expr) { _bz_assign(expr, _bz_divide_update()); return *this; } template template inline TinyVector& TinyVector::operator%=(_bz_VecExpr expr) { _bz_assign(expr, _bz_mod_update()); return *this; } template template inline TinyVector& TinyVector::operator^=(_bz_VecExpr expr) { _bz_assign(expr, _bz_xor_update()); return *this; } template template inline TinyVector& TinyVector::operator&=(_bz_VecExpr expr) { _bz_assign(expr, _bz_bitand_update()); return *this; } template template inline TinyVector& TinyVector::operator|=(_bz_VecExpr expr) { _bz_assign(expr, _bz_bitor_update()); return *this; } template template inline TinyVector& TinyVector::operator<<=(_bz_VecExpr expr) { _bz_assign(expr, _bz_shiftl_update()); return *this; } template template inline TinyVector& TinyVector::operator>>=(_bz_VecExpr expr) { _bz_assign(expr, _bz_shiftr_update()); return *this; } /***************************************************************************** * Assignment operators with scalar operand */ template inline TinyVector& TinyVector::initialize(P_numtype x) { #ifndef BZ_KCC_COPY_PROPAGATION_KLUDGE typedef _bz_VecExprConstant T_expr; (*this) = _bz_VecExpr(T_expr(x)); #else // Avoid using the copy propagation kludge for this simple // operation. for (int i=0; i < N_length; ++i) data_[i] = x; #endif return *this; } template inline TinyVector& TinyVector::operator+=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) += _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator-=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) -= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator*=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) *= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator/=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) /= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator%=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) %= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator^=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) ^= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator&=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) &= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator|=(P_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) |= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator<<=(int x) { typedef _bz_VecExprConstant T_expr; (*this) <<= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator>>=(int x) { typedef _bz_VecExprConstant T_expr; (*this) >>= _bz_VecExpr(T_expr(x)); return *this; } /***************************************************************************** * Assignment operators with TinyVector operand */ template template inline TinyVector& TinyVector::operator=(const TinyVector& x) { (*this) = _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator+=(const TinyVector& x) { (*this) += _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator-=(const TinyVector& x) { (*this) -= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator*=(const TinyVector& x) { (*this) *= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator/=(const TinyVector& x) { (*this) /= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator%=(const TinyVector& x) { (*this) %= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator^=(const TinyVector& x) { (*this) ^= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator&=(const TinyVector& x) { (*this) &= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator|=(const TinyVector& x) { (*this) |= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator<<=(const TinyVector& x) { (*this) <<= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } template template inline TinyVector& TinyVector::operator>>=(const TinyVector& x) { (*this) >>= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.begin()); return *this; } /***************************************************************************** * Assignment operators with Vector operand */ template template inline TinyVector& TinyVector::operator=(const Vector& x) { (*this) = x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator+=(const Vector& x) { (*this) += x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator-=(const Vector& x) { (*this) -= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator*=(const Vector& x) { (*this) *= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator/=(const Vector& x) { (*this) /= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator%=(const Vector& x) { (*this) %= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator^=(const Vector& x) { (*this) ^= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator&=(const Vector& x) { (*this) &= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator|=(const Vector& x) { (*this) |= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator<<=(const Vector& x) { (*this) <<= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator>>=(const Vector& x) { (*this) >>= x._bz_asVecExpr(); return *this; } /***************************************************************************** * Assignment operators with Range operand */ template inline TinyVector& TinyVector::operator=(Range r) { (*this) = r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator+=(Range r) { (*this) += r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator-=(Range r) { (*this) -= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator*=(Range r) { (*this) *= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator/=(Range r) { (*this) /= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator%=(Range r) { (*this) %= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator^=(Range r) { (*this) ^= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator&=(Range r) { (*this) &= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator|=(Range r) { (*this) |= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator<<=(Range r) { (*this) <<= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator>>=(Range r) { (*this) >>= r._bz_asVecExpr(); return *this; } /***************************************************************************** * Assignment operators with VectorPick operand */ template template inline TinyVector& TinyVector::operator=(const VectorPick& x) { (*this) = x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator+=(const VectorPick& x) { (*this) += x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator-=(const VectorPick& x) { (*this) -= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator*=(const VectorPick& x) { (*this) *= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator/=(const VectorPick& x) { (*this) /= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator%=(const VectorPick& x) { (*this) %= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator^=(const VectorPick& x) { (*this) ^= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator&=(const VectorPick& x) { (*this) &= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator|=(const VectorPick& x) { (*this) |= x._bz_asVecExpr(); return *this; } template template inline TinyVector& TinyVector::operator>>=(const VectorPick& x) { (*this) <<= x._bz_asVecExpr(); return *this; } BZ_NAMESPACE_END #endif // BZ_TINYVEC_CC