| 1 | /*
 | 
|---|
| 2 |  * $Id: vecpick.cc,v 1.1.1.1 1999-11-26 16:37:06 ansari Exp $
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
 | 
|---|
| 5 |  * All rights reserved.  Please see <blitz/blitz.h> for terms and
 | 
|---|
| 6 |  * conditions of use.
 | 
|---|
| 7 |  *
 | 
|---|
| 8 |  * $Log: not supported by cvs2svn $
 | 
|---|
| 9 | // Revision 1.1.1.1  1999/04/09  17:58:59  ansari
 | 
|---|
| 10 | // Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
 | 
|---|
| 11 | //
 | 
|---|
| 12 |  * Revision 1.5  1998/03/14 00:04:47  tveldhui
 | 
|---|
| 13 |  * 0.2-alpha-05
 | 
|---|
| 14 |  *
 | 
|---|
| 15 |  * Revision 1.4  1997/07/16 14:51:20  tveldhui
 | 
|---|
| 16 |  * Update: Alpha release 0.2 (Arrays)
 | 
|---|
| 17 |  *
 | 
|---|
| 18 |  * Revision 1.3  1997/01/24 14:42:00  tveldhui
 | 
|---|
| 19 |  * Periodic RCS update
 | 
|---|
| 20 |  *
 | 
|---|
| 21 |  */
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #ifndef BZ_VECPICK_CC
 | 
|---|
| 24 | #define BZ_VECPICK_CC
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #ifndef BZ_VECPICK_H
 | 
|---|
| 27 |  #include <blitz/vecpick.h>
 | 
|---|
| 28 | #endif
 | 
|---|
| 29 | 
 | 
|---|
| 30 | #ifndef BZ_UPDATE_H
 | 
|---|
| 31 |  #include <blitz/update.h>
 | 
|---|
| 32 | #endif
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #ifndef BZ_RANDOM_H
 | 
|---|
| 35 |  #include <blitz/random.h>
 | 
|---|
| 36 | #endif
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #ifndef BZ_VECEXPR_H
 | 
|---|
| 39 |  #include <blitz/vecexpr.h>
 | 
|---|
| 40 | #endif
 | 
|---|
| 41 | 
 | 
|---|
| 42 | #ifndef BZ_RANDOM_H
 | 
|---|
| 43 |  #include <blitz/random.h>
 | 
|---|
| 44 | #endif
 | 
|---|
| 45 | BZ_NAMESPACE(blitz)
 | 
|---|
| 46 | 
 | 
|---|
| 47 | /*****************************************************************************
 | 
|---|
| 48 |  * Assignment operators with vector expression operand
 | 
|---|
| 49 |  */
 | 
|---|
| 50 | 
 | 
|---|
| 51 | template<class P_numtype> template<class P_expr, class P_updater>
 | 
|---|
| 52 | inline
 | 
|---|
| 53 | void VectorPick<P_numtype>::_bz_assign(P_expr expr, P_updater)
 | 
|---|
| 54 | {
 | 
|---|
| 55 |     BZPRECONDITION(expr.length(length()) == length());
 | 
|---|
| 56 | 
 | 
|---|
| 57 |     // If all vectors in the expression, plus the vector to which the
 | 
|---|
| 58 |     // result is being assigned have unit stride, then avoid stride
 | 
|---|
| 59 |     // calculations.
 | 
|---|
| 60 |     if (_bz_hasFastAccess() && expr._bz_hasFastAccess())
 | 
|---|
| 61 |     {
 | 
|---|
| 62 | #ifndef BZ_PARTIAL_LOOP_UNROLL
 | 
|---|
| 63 |         for (int i=0; i < length(); ++i)
 | 
|---|
| 64 |             P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
 | 
|---|
| 65 | #else
 | 
|---|
| 66 |         // Unwind the inner loop, five elements at a time.
 | 
|---|
| 67 |         int leftover = length() % 5;
 | 
|---|
| 68 | 
 | 
|---|
| 69 |         int i=0;
 | 
|---|
| 70 |         for (; i < leftover; ++i)
 | 
|---|
| 71 |             P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
 | 
|---|
| 72 | 
 | 
|---|
| 73 |         for (; i < length(); i += 5)
 | 
|---|
| 74 |         {
 | 
|---|
| 75 |             P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i));
 | 
|---|
| 76 |             P_updater::update(vector_(index_(i+1)), expr._bz_fastAccess(i+1));
 | 
|---|
| 77 |             P_updater::update(vector_(index_(i+2)), expr._bz_fastAccess(i+2));
 | 
|---|
| 78 |             P_updater::update(vector_(index_(i+3)), expr._bz_fastAccess(i+3));
 | 
|---|
| 79 |             P_updater::update(vector_(index_(i+4)), expr._bz_fastAccess(i+4));
 | 
|---|
| 80 |         }
 | 
|---|
| 81 | #endif
 | 
|---|
| 82 |     }
 | 
|---|
| 83 |     else {
 | 
|---|
| 84 |         // Not all unit strides -- have to access all the vector elements
 | 
|---|
| 85 |         // as data_[i*stride_], which is slower.
 | 
|---|
| 86 |         for (int i=0; i < length(); ++i)
 | 
|---|
| 87 |             P_updater::update(vector_[index_[i]], expr[i]);
 | 
|---|
| 88 |     }
 | 
|---|
| 89 | }
 | 
|---|
| 90 | 
 | 
|---|
| 91 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 92 | inline VectorPick<P_numtype>& 
 | 
|---|
| 93 | VectorPick<P_numtype>::operator=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 94 | {
 | 
|---|
| 95 |     BZPRECONDITION(expr.length(length()) == length());
 | 
|---|
| 96 | 
 | 
|---|
| 97 |     // If all vectors in the expression, plus the vector to which the
 | 
|---|
| 98 |     // result is being assigned have unit stride, then avoid stride
 | 
|---|
| 99 |     // calculations.
 | 
|---|
| 100 |     if (_bz_hasFastAccess() && expr._bz_hasFastAccess())
 | 
|---|
| 101 |     {
 | 
|---|
| 102 | #ifndef BZ_PARTIAL_LOOP_UNROLL
 | 
|---|
| 103 |         for (int i=0; i < length(); ++i)
 | 
|---|
| 104 |             (*this)(i) = expr._bz_fastAccess(i);
 | 
|---|
| 105 | #else
 | 
|---|
| 106 |         // Unwind the inner loop, five elements at a time.
 | 
|---|
| 107 |         int leftover = length() % 5;
 | 
|---|
| 108 | 
 | 
|---|
| 109 |         int i=0;
 | 
|---|
| 110 |         for (; i < leftover; ++i)
 | 
|---|
| 111 |             (*this)(i) = expr._bz_fastAccess(i);
 | 
|---|
| 112 | 
 | 
|---|
| 113 |         for (; i < length(); i += 5)
 | 
|---|
| 114 |         {
 | 
|---|
| 115 |             (*this)(i) = expr._bz_fastAccess(i);
 | 
|---|
| 116 |             (*this)(i+1) = expr._bz_fastAccess(i+1);
 | 
|---|
| 117 |             (*this)(i+2) = expr._bz_fastAccess(i+2);
 | 
|---|
| 118 |             (*this)(i+3) = expr._bz_fastAccess(i+3);
 | 
|---|
| 119 |             (*this)(i+4) = expr._bz_fastAccess(i+4);
 | 
|---|
| 120 |         }
 | 
|---|
| 121 | #endif
 | 
|---|
| 122 |     }
 | 
|---|
| 123 |     else {
 | 
|---|
| 124 |         // Not all unit strides -- have to access all the vector elements
 | 
|---|
| 125 |         // as data_[i*stride_], which is slower.
 | 
|---|
| 126 |         for (int i=0; i < length(); ++i)
 | 
|---|
| 127 |             (*this)[i] = expr[i];
 | 
|---|
| 128 |     }
 | 
|---|
| 129 |     return *this;
 | 
|---|
| 130 | }
 | 
|---|
| 131 | 
 | 
|---|
| 132 | 
 | 
|---|
| 133 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 134 | inline VectorPick<P_numtype>& 
 | 
|---|
| 135 | VectorPick<P_numtype>::operator+=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 136 | {
 | 
|---|
| 137 |     _bz_assign(expr, _bz_plus_update<P_numtype,
 | 
|---|
| 138 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 139 |     return *this;
 | 
|---|
| 140 | }
 | 
|---|
| 141 | 
 | 
|---|
| 142 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 143 | inline VectorPick<P_numtype>& 
 | 
|---|
| 144 | VectorPick<P_numtype>::operator-=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 145 | {
 | 
|---|
| 146 |     _bz_assign(expr, _bz_minus_update<P_numtype,
 | 
|---|
| 147 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 148 |     return *this;
 | 
|---|
| 149 | }
 | 
|---|
| 150 | 
 | 
|---|
| 151 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 152 | inline VectorPick<P_numtype>& 
 | 
|---|
| 153 | VectorPick<P_numtype>::operator*=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 154 | {
 | 
|---|
| 155 |     _bz_assign(expr, _bz_multiply_update<P_numtype,
 | 
|---|
| 156 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 157 |     return *this;
 | 
|---|
| 158 | }
 | 
|---|
| 159 | 
 | 
|---|
| 160 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 161 | inline VectorPick<P_numtype>& 
 | 
|---|
| 162 | VectorPick<P_numtype>::operator/=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 163 | {
 | 
|---|
| 164 |     _bz_assign(expr, _bz_divide_update<P_numtype,
 | 
|---|
| 165 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 166 |     return *this;
 | 
|---|
| 167 | }
 | 
|---|
| 168 | 
 | 
|---|
| 169 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 170 | inline VectorPick<P_numtype>& 
 | 
|---|
| 171 | VectorPick<P_numtype>::operator%=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 172 | {
 | 
|---|
| 173 |     _bz_assign(expr, _bz_mod_update<P_numtype,
 | 
|---|
| 174 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 175 |     return *this;
 | 
|---|
| 176 | }
 | 
|---|
| 177 | 
 | 
|---|
| 178 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 179 | inline VectorPick<P_numtype>& 
 | 
|---|
| 180 | VectorPick<P_numtype>::operator^=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 181 | {
 | 
|---|
| 182 |     _bz_assign(expr, _bz_xor_update<P_numtype,
 | 
|---|
| 183 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 184 |     return *this;
 | 
|---|
| 185 | }
 | 
|---|
| 186 | 
 | 
|---|
| 187 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 188 | inline VectorPick<P_numtype>& 
 | 
|---|
| 189 | VectorPick<P_numtype>::operator&=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 190 | {
 | 
|---|
| 191 |     _bz_assign(expr, _bz_bitand_update<P_numtype,
 | 
|---|
| 192 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 193 |     return *this;
 | 
|---|
| 194 | }
 | 
|---|
| 195 | 
 | 
|---|
| 196 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 197 | inline VectorPick<P_numtype>& 
 | 
|---|
| 198 | VectorPick<P_numtype>::operator|=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 199 | {
 | 
|---|
| 200 |     _bz_assign(expr, _bz_bitor_update<P_numtype,
 | 
|---|
| 201 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 202 |     return *this;
 | 
|---|
| 203 | }
 | 
|---|
| 204 | 
 | 
|---|
| 205 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 206 | inline VectorPick<P_numtype>& 
 | 
|---|
| 207 | VectorPick<P_numtype>::operator>>=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 208 | {
 | 
|---|
| 209 |     _bz_assign(expr, _bz_shiftr_update<P_numtype,
 | 
|---|
| 210 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 211 |     return *this;
 | 
|---|
| 212 | }
 | 
|---|
| 213 | 
 | 
|---|
| 214 | template<class P_numtype> template<class P_expr>
 | 
|---|
| 215 | inline VectorPick<P_numtype>& 
 | 
|---|
| 216 | VectorPick<P_numtype>::operator<<=(_bz_VecExpr<P_expr> expr)
 | 
|---|
| 217 | {
 | 
|---|
| 218 |     _bz_assign(expr, _bz_shiftl_update<P_numtype,
 | 
|---|
| 219 |         _bz_typename P_expr::T_numtype>());
 | 
|---|
| 220 |     return *this;
 | 
|---|
| 221 | }
 | 
|---|
| 222 | 
 | 
|---|
| 223 | /*****************************************************************************
 | 
|---|
| 224 |  * Assignment operators with scalar operand
 | 
|---|
| 225 |  */
 | 
|---|
| 226 | 
 | 
|---|
| 227 | template<class P_numtype>
 | 
|---|
| 228 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(P_numtype x)
 | 
|---|
| 229 | {
 | 
|---|
| 230 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 231 |     (*this) = _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 232 |     return *this;
 | 
|---|
| 233 | }
 | 
|---|
| 234 | 
 | 
|---|
| 235 | template<class P_numtype>
 | 
|---|
| 236 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(P_numtype x)
 | 
|---|
| 237 | {
 | 
|---|
| 238 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 239 |     (*this) += _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 240 |     return *this;
 | 
|---|
| 241 | }
 | 
|---|
| 242 | 
 | 
|---|
| 243 | template<class P_numtype>
 | 
|---|
| 244 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(P_numtype x)
 | 
|---|
| 245 | {
 | 
|---|
| 246 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 247 |     (*this) -= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 248 |     return *this;
 | 
|---|
| 249 | }
 | 
|---|
| 250 | 
 | 
|---|
| 251 | template<class P_numtype>
 | 
|---|
| 252 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(P_numtype x)
 | 
|---|
| 253 | {
 | 
|---|
| 254 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 255 |     (*this) *= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 256 |     return *this;
 | 
|---|
| 257 | }
 | 
|---|
| 258 | 
 | 
|---|
| 259 | template<class P_numtype>
 | 
|---|
| 260 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(P_numtype x)
 | 
|---|
| 261 | {
 | 
|---|
| 262 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 263 |     (*this) /= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 264 |     return *this;
 | 
|---|
| 265 | }
 | 
|---|
| 266 | 
 | 
|---|
| 267 | template<class P_numtype>
 | 
|---|
| 268 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(P_numtype x)
 | 
|---|
| 269 | {
 | 
|---|
| 270 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 271 |     (*this) %= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 272 |     return *this;
 | 
|---|
| 273 | }
 | 
|---|
| 274 | 
 | 
|---|
| 275 | template<class P_numtype>
 | 
|---|
| 276 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(P_numtype x)
 | 
|---|
| 277 | {
 | 
|---|
| 278 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 279 |     (*this) ^= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 280 |     return *this;
 | 
|---|
| 281 | }
 | 
|---|
| 282 | 
 | 
|---|
| 283 | template<class P_numtype>
 | 
|---|
| 284 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(P_numtype x)
 | 
|---|
| 285 | {
 | 
|---|
| 286 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 287 |     (*this) &= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 288 |     return *this;
 | 
|---|
| 289 | }
 | 
|---|
| 290 | 
 | 
|---|
| 291 | template<class P_numtype>
 | 
|---|
| 292 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(P_numtype x)
 | 
|---|
| 293 | {
 | 
|---|
| 294 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 295 |     (*this) |= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 296 |     return *this;
 | 
|---|
| 297 | }
 | 
|---|
| 298 | 
 | 
|---|
| 299 | template<class P_numtype>
 | 
|---|
| 300 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(int x)
 | 
|---|
| 301 | {
 | 
|---|
| 302 |     typedef _bz_VecExprConstant<int> T_expr;
 | 
|---|
| 303 |     (*this) >>= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 304 |     return *this;
 | 
|---|
| 305 | }
 | 
|---|
| 306 | 
 | 
|---|
| 307 | template<class P_numtype>
 | 
|---|
| 308 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(int x)
 | 
|---|
| 309 | {
 | 
|---|
| 310 |     typedef _bz_VecExprConstant<P_numtype> T_expr;
 | 
|---|
| 311 |     (*this) <<= _bz_VecExpr<T_expr>(T_expr(x));
 | 
|---|
| 312 |     return *this;
 | 
|---|
| 313 | }
 | 
|---|
| 314 | 
 | 
|---|
| 315 | /*****************************************************************************
 | 
|---|
| 316 |  * Assignment operators with vector operand
 | 
|---|
| 317 |  */
 | 
|---|
| 318 | 
 | 
|---|
| 319 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 320 | inline VectorPick<P_numtype>& 
 | 
|---|
| 321 | VectorPick<P_numtype>::operator=(const Vector<P_numtype2>& x)
 | 
|---|
| 322 | {
 | 
|---|
| 323 |     (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 324 |     return *this;
 | 
|---|
| 325 | }
 | 
|---|
| 326 | 
 | 
|---|
| 327 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 328 | inline VectorPick<P_numtype>&
 | 
|---|
| 329 | VectorPick<P_numtype>::operator+=(const Vector<P_numtype2>& x)
 | 
|---|
| 330 | {
 | 
|---|
| 331 |     (*this) += _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 332 |     return *this;
 | 
|---|
| 333 | }
 | 
|---|
| 334 | 
 | 
|---|
| 335 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 336 | inline VectorPick<P_numtype>&
 | 
|---|
| 337 | VectorPick<P_numtype>::operator-=(const Vector<P_numtype2>& x)
 | 
|---|
| 338 | {
 | 
|---|
| 339 |     (*this) -= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 340 |     return *this;
 | 
|---|
| 341 | }
 | 
|---|
| 342 | 
 | 
|---|
| 343 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 344 | inline VectorPick<P_numtype>&
 | 
|---|
| 345 | VectorPick<P_numtype>::operator*=(const Vector<P_numtype2>& x)
 | 
|---|
| 346 | {
 | 
|---|
| 347 |     (*this) *= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 348 |     return *this;
 | 
|---|
| 349 | }
 | 
|---|
| 350 | 
 | 
|---|
| 351 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 352 | inline VectorPick<P_numtype>&
 | 
|---|
| 353 | VectorPick<P_numtype>::operator/=(const Vector<P_numtype2>& x)
 | 
|---|
| 354 | {
 | 
|---|
| 355 |     (*this) /= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 356 |     return *this;
 | 
|---|
| 357 | }
 | 
|---|
| 358 | 
 | 
|---|
| 359 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 360 | inline VectorPick<P_numtype>&
 | 
|---|
| 361 | VectorPick<P_numtype>::operator%=(const Vector<P_numtype2>& x)
 | 
|---|
| 362 | {
 | 
|---|
| 363 |     (*this) %= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 364 |     return *this;
 | 
|---|
| 365 | }
 | 
|---|
| 366 | 
 | 
|---|
| 367 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 368 | inline VectorPick<P_numtype>&
 | 
|---|
| 369 | VectorPick<P_numtype>::operator^=(const Vector<P_numtype2>& x)
 | 
|---|
| 370 | {
 | 
|---|
| 371 |     (*this) ^= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 372 |     return *this;
 | 
|---|
| 373 | }
 | 
|---|
| 374 | 
 | 
|---|
| 375 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 376 | inline VectorPick<P_numtype>&
 | 
|---|
| 377 | VectorPick<P_numtype>::operator&=(const Vector<P_numtype2>& x)
 | 
|---|
| 378 | {
 | 
|---|
| 379 |     (*this) &= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 380 |     return *this;
 | 
|---|
| 381 | }
 | 
|---|
| 382 | 
 | 
|---|
| 383 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 384 | inline VectorPick<P_numtype>&
 | 
|---|
| 385 | VectorPick<P_numtype>::operator|=(const Vector<P_numtype2>& x)
 | 
|---|
| 386 | {
 | 
|---|
| 387 |     (*this) |= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 388 |     return *this;
 | 
|---|
| 389 | }
 | 
|---|
| 390 | 
 | 
|---|
| 391 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 392 | inline VectorPick<P_numtype>&
 | 
|---|
| 393 | VectorPick<P_numtype>::operator<<=(const Vector<P_numtype2>& x)
 | 
|---|
| 394 | {
 | 
|---|
| 395 |     (*this) <<= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 396 |     return *this;
 | 
|---|
| 397 | }
 | 
|---|
| 398 | 
 | 
|---|
| 399 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 400 | inline VectorPick<P_numtype>&
 | 
|---|
| 401 | VectorPick<P_numtype>::operator>>=(const Vector<P_numtype2>& x)
 | 
|---|
| 402 | {
 | 
|---|
| 403 |     (*this) >>= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
 | 
|---|
| 404 |     return *this;
 | 
|---|
| 405 | }
 | 
|---|
| 406 | 
 | 
|---|
| 407 | /*****************************************************************************
 | 
|---|
| 408 |  * Assignment operators with Range operand
 | 
|---|
| 409 |  */
 | 
|---|
| 410 | 
 | 
|---|
| 411 | template<class P_numtype>
 | 
|---|
| 412 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(Range r)
 | 
|---|
| 413 | {
 | 
|---|
| 414 |     (*this) = _bz_VecExpr<Range>(r);
 | 
|---|
| 415 |     return *this;
 | 
|---|
| 416 | }
 | 
|---|
| 417 | 
 | 
|---|
| 418 | template<class P_numtype>
 | 
|---|
| 419 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(Range r)
 | 
|---|
| 420 | {
 | 
|---|
| 421 |     (*this) += _bz_VecExpr<Range>(r);
 | 
|---|
| 422 |     return *this;
 | 
|---|
| 423 | }
 | 
|---|
| 424 | 
 | 
|---|
| 425 | template<class P_numtype>
 | 
|---|
| 426 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(Range r)
 | 
|---|
| 427 | {
 | 
|---|
| 428 |     (*this) -= _bz_VecExpr<Range>(r);
 | 
|---|
| 429 |     return *this;
 | 
|---|
| 430 | }
 | 
|---|
| 431 | 
 | 
|---|
| 432 | template<class P_numtype>
 | 
|---|
| 433 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(Range r)
 | 
|---|
| 434 | {
 | 
|---|
| 435 |     (*this) *= _bz_VecExpr<Range>(r);
 | 
|---|
| 436 |     return *this;
 | 
|---|
| 437 | }
 | 
|---|
| 438 | 
 | 
|---|
| 439 | template<class P_numtype>
 | 
|---|
| 440 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(Range r)
 | 
|---|
| 441 | {
 | 
|---|
| 442 |     (*this) /= _bz_VecExpr<Range>(r);
 | 
|---|
| 443 |     return *this;
 | 
|---|
| 444 | }
 | 
|---|
| 445 | 
 | 
|---|
| 446 | template<class P_numtype>
 | 
|---|
| 447 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(Range r)
 | 
|---|
| 448 | {
 | 
|---|
| 449 |     (*this) %= _bz_VecExpr<Range>(r);
 | 
|---|
| 450 |     return *this;
 | 
|---|
| 451 | }
 | 
|---|
| 452 | 
 | 
|---|
| 453 | template<class P_numtype>
 | 
|---|
| 454 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(Range r)
 | 
|---|
| 455 | {
 | 
|---|
| 456 |     (*this) ^= _bz_VecExpr<Range>(r);
 | 
|---|
| 457 |     return *this;
 | 
|---|
| 458 | }
 | 
|---|
| 459 | 
 | 
|---|
| 460 | template<class P_numtype>
 | 
|---|
| 461 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(Range r)
 | 
|---|
| 462 | {
 | 
|---|
| 463 |     (*this) &= _bz_VecExpr<Range>(r);
 | 
|---|
| 464 |     return *this;
 | 
|---|
| 465 | }
 | 
|---|
| 466 | 
 | 
|---|
| 467 | template<class P_numtype>
 | 
|---|
| 468 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(Range r)
 | 
|---|
| 469 | {
 | 
|---|
| 470 |     (*this) |= _bz_VecExpr<Range>(r);
 | 
|---|
| 471 |     return *this;
 | 
|---|
| 472 | }
 | 
|---|
| 473 | 
 | 
|---|
| 474 | template<class P_numtype>
 | 
|---|
| 475 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(Range r)
 | 
|---|
| 476 | {
 | 
|---|
| 477 |     (*this) >>= _bz_VecExpr<Range>(r);
 | 
|---|
| 478 |     return *this;
 | 
|---|
| 479 | }
 | 
|---|
| 480 | 
 | 
|---|
| 481 | template<class P_numtype>
 | 
|---|
| 482 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(Range r)
 | 
|---|
| 483 | {
 | 
|---|
| 484 |     (*this) <<= _bz_VecExpr<Range>(r);
 | 
|---|
| 485 |     return *this;
 | 
|---|
| 486 | }
 | 
|---|
| 487 | 
 | 
|---|
| 488 | /*****************************************************************************
 | 
|---|
| 489 |  * Assignment operators with VectorPick operand
 | 
|---|
| 490 |  */
 | 
|---|
| 491 | 
 | 
|---|
| 492 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 493 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(const 
 | 
|---|
| 494 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 495 | {
 | 
|---|
| 496 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 497 |     (*this) = _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 498 |     return *this;
 | 
|---|
| 499 | }
 | 
|---|
| 500 | 
 | 
|---|
| 501 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 502 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(const
 | 
|---|
| 503 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 504 | {
 | 
|---|
| 505 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 506 |     (*this) += _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 507 |     return *this;
 | 
|---|
| 508 | }
 | 
|---|
| 509 | 
 | 
|---|
| 510 | 
 | 
|---|
| 511 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 512 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(const
 | 
|---|
| 513 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 514 | {
 | 
|---|
| 515 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 516 |     (*this) -= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 517 |     return *this;
 | 
|---|
| 518 | }
 | 
|---|
| 519 | 
 | 
|---|
| 520 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 521 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(const
 | 
|---|
| 522 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 523 | {
 | 
|---|
| 524 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 525 |     (*this) *= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 526 |     return *this;
 | 
|---|
| 527 | }
 | 
|---|
| 528 | 
 | 
|---|
| 529 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 530 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(const
 | 
|---|
| 531 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 532 | {
 | 
|---|
| 533 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 534 |     (*this) /= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 535 |     return *this;
 | 
|---|
| 536 | }
 | 
|---|
| 537 | 
 | 
|---|
| 538 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 539 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(const
 | 
|---|
| 540 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 541 | {
 | 
|---|
| 542 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 543 |     (*this) %= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 544 |     return *this;
 | 
|---|
| 545 | }
 | 
|---|
| 546 | 
 | 
|---|
| 547 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 548 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(const
 | 
|---|
| 549 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 550 | {
 | 
|---|
| 551 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 552 |     (*this) ^= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 553 |     return *this;
 | 
|---|
| 554 | }
 | 
|---|
| 555 | 
 | 
|---|
| 556 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 557 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(const
 | 
|---|
| 558 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 559 | {
 | 
|---|
| 560 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 561 |     (*this) &= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 562 |     return *this;
 | 
|---|
| 563 | }
 | 
|---|
| 564 | 
 | 
|---|
| 565 | template<class P_numtype> template<class P_numtype2>
 | 
|---|
| 566 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(const
 | 
|---|
| 567 |     VectorPick<P_numtype2>& x)
 | 
|---|
| 568 | {
 | 
|---|
| 569 |     typedef VectorPickIterConst<P_numtype2> T_expr;
 | 
|---|
| 570 |     (*this) |= _bz_VecExpr<T_expr>(x.begin());
 | 
|---|
| 571 |     return *this;
 | 
|---|
| 572 | }
 | 
|---|
| 573 | 
 | 
|---|
| 574 | /*****************************************************************************
 | 
|---|
| 575 |  * Assignment operators with Random operand
 | 
|---|
| 576 |  */
 | 
|---|
| 577 | 
 | 
|---|
| 578 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 579 | VectorPick<P_numtype>& 
 | 
|---|
| 580 | VectorPick<P_numtype>::operator=(Random<P_distribution>& rand)
 | 
|---|
| 581 | {
 | 
|---|
| 582 |     (*this) = _bz_VecExpr<_bz_VecExprRandom<P_distribution> > 
 | 
|---|
| 583 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 584 |     return *this;
 | 
|---|
| 585 | }
 | 
|---|
| 586 | 
 | 
|---|
| 587 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 588 | VectorPick<P_numtype>& 
 | 
|---|
| 589 | VectorPick<P_numtype>::operator+=(Random<P_distribution>& rand)
 | 
|---|
| 590 | {
 | 
|---|
| 591 |     (*this) += _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 592 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 593 |     return *this;
 | 
|---|
| 594 | }
 | 
|---|
| 595 | 
 | 
|---|
| 596 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 597 | VectorPick<P_numtype>& 
 | 
|---|
| 598 | VectorPick<P_numtype>::operator-=(Random<P_distribution>& rand)
 | 
|---|
| 599 | {
 | 
|---|
| 600 |     (*this) -= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 601 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 602 |     return *this;
 | 
|---|
| 603 | }
 | 
|---|
| 604 | 
 | 
|---|
| 605 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 606 | VectorPick<P_numtype>& 
 | 
|---|
| 607 | VectorPick<P_numtype>::operator*=(Random<P_distribution>& rand)
 | 
|---|
| 608 | {
 | 
|---|
| 609 |     (*this) *= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 610 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 611 |     return *this;
 | 
|---|
| 612 | }
 | 
|---|
| 613 | 
 | 
|---|
| 614 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 615 | VectorPick<P_numtype>& 
 | 
|---|
| 616 | VectorPick<P_numtype>::operator/=(Random<P_distribution>& rand)
 | 
|---|
| 617 | {
 | 
|---|
| 618 |     (*this) /= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 619 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 620 |     return *this;
 | 
|---|
| 621 | }
 | 
|---|
| 622 | 
 | 
|---|
| 623 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 624 | VectorPick<P_numtype>& 
 | 
|---|
| 625 | VectorPick<P_numtype>::operator%=(Random<P_distribution>& rand)
 | 
|---|
| 626 | {
 | 
|---|
| 627 |     (*this) %= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 628 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 629 |     return *this;
 | 
|---|
| 630 | }
 | 
|---|
| 631 | 
 | 
|---|
| 632 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 633 | VectorPick<P_numtype>& 
 | 
|---|
| 634 | VectorPick<P_numtype>::operator^=(Random<P_distribution>& rand)
 | 
|---|
| 635 | {
 | 
|---|
| 636 |     (*this) ^= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 637 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 638 |     return *this;
 | 
|---|
| 639 | }
 | 
|---|
| 640 | 
 | 
|---|
| 641 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 642 | VectorPick<P_numtype>& 
 | 
|---|
| 643 | VectorPick<P_numtype>::operator&=(Random<P_distribution>& rand)
 | 
|---|
| 644 | {
 | 
|---|
| 645 |     (*this) &= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 646 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 647 |     return *this;
 | 
|---|
| 648 | }
 | 
|---|
| 649 | 
 | 
|---|
| 650 | template<class P_numtype> template<class P_distribution>
 | 
|---|
| 651 | VectorPick<P_numtype>& 
 | 
|---|
| 652 | VectorPick<P_numtype>::operator|=(Random<P_distribution>& rand)
 | 
|---|
| 653 | {
 | 
|---|
| 654 |     (*this) |= _bz_VecExpr<_bz_VecExprRandom<P_distribution> >
 | 
|---|
| 655 |         (_bz_VecExprRandom<P_distribution>(rand));
 | 
|---|
| 656 |     return *this;
 | 
|---|
| 657 | }
 | 
|---|
| 658 | 
 | 
|---|
| 659 | BZ_NAMESPACE_END
 | 
|---|
| 660 | 
 | 
|---|
| 661 | #endif // BZ_VECPICK_CC
 | 
|---|