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