/*************************************************************************** * blitz/tinyvec.cc Declaration of TinyVector methods * * $Id: tinyvec.cc,v 1.9 2005/10/17 21:43:45 julianc Exp $ * * Copyright (C) 1997-2001 Todd Veldhuizen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Suggestions: blitz-dev@oonumerics.org * Bugs: blitz-bugs@oonumerics.org * * For more information, please see the Blitz++ Home Page: * http://oonumerics.org/blitz/ * ***************************************************************************/ #ifndef BZ_TINYVEC_CC #define BZ_TINYVEC_CC #include #include #include #include BZ_NAMESPACE(blitz) template inline TinyVector::TinyVector(const 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 TinyVector::TinyVector(const TinyVector& x) { for (int i=0; i < N_length; ++i) data_[i] = static_cast(x[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); } } // Constructor added by Peter Nordlund (peter.nordlund@ind.af.se) template template inline TinyVector::TinyVector(_bz_VecExpr expr) { _bz_assign(expr, _bz_update()); } /***************************************************************************** * 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(const T_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+=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) += _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator-=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) -= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator*=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) *= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator/=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) /= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator%=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) %= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator^=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) ^= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator&=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) &= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator|=(const T_numtype x) { typedef _bz_VecExprConstant T_expr; (*this) |= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator<<=(const int x) { typedef _bz_VecExprConstant T_expr; (*this) <<= _bz_VecExpr(T_expr(x)); return *this; } template inline TinyVector& TinyVector::operator>>=(const 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.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator+=(const TinyVector& x) { (*this) += _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator-=(const TinyVector& x) { (*this) -= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator*=(const TinyVector& x) { (*this) *= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator/=(const TinyVector& x) { (*this) /= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator%=(const TinyVector& x) { (*this) %= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator^=(const TinyVector& x) { (*this) ^= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator&=(const TinyVector& x) { (*this) &= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator|=(const TinyVector& x) { (*this) |= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator<<=(const TinyVector& x) { (*this) <<= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); return *this; } template template inline TinyVector& TinyVector::operator>>=(const TinyVector& x) { (*this) >>= _bz_VecExpr<_bz_typename TinyVector::T_constIterator>(x.beginFast()); 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=(const Range& r) { (*this) = r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator+=(const Range& r) { (*this) += r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator-=(const Range& r) { (*this) -= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator*=(const Range& r) { (*this) *= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator/=(const Range& r) { (*this) /= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator%=(const Range& r) { (*this) %= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator^=(const Range& r) { (*this) ^= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator&=(const Range& r) { (*this) &= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator|=(const Range& r) { (*this) |= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator<<=(const Range& r) { (*this) <<= r._bz_asVecExpr(); return *this; } template inline TinyVector& TinyVector::operator>>=(const 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