1 | /* |
---|
2 | * $Id: vecpick.cc,v 1.4 2005/10/06 23:29:34 julianc Exp $ |
---|
3 | * |
---|
4 | * Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
5 | * All rights reserved. Please see <blitz/blitz.h> for terms and |
---|
6 | * conditions of use. |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef BZ_VECPICK_CC |
---|
11 | #define BZ_VECPICK_CC |
---|
12 | |
---|
13 | #include <blitz/vecpick.h> |
---|
14 | #include <blitz/update.h> |
---|
15 | #include <blitz/random.h> |
---|
16 | #include <blitz/vecexpr.h> |
---|
17 | |
---|
18 | BZ_NAMESPACE(blitz) |
---|
19 | |
---|
20 | /***************************************************************************** |
---|
21 | * Assignment operators with vector expression operand |
---|
22 | */ |
---|
23 | |
---|
24 | template<typename P_numtype> template<typename P_expr, typename P_updater> |
---|
25 | inline |
---|
26 | void VectorPick<P_numtype>::_bz_assign(P_expr expr, P_updater) |
---|
27 | { |
---|
28 | BZPRECONDITION(expr.length(length()) == length()); |
---|
29 | |
---|
30 | // If all vectors in the expression, plus the vector to which the |
---|
31 | // result is being assigned have unit stride, then avoid stride |
---|
32 | // calculations. |
---|
33 | if (_bz_hasFastAccess() && expr._bz_hasFastAccess()) |
---|
34 | { |
---|
35 | #ifndef BZ_PARTIAL_LOOP_UNROLL |
---|
36 | for (int i=0; i < length(); ++i) |
---|
37 | P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i)); |
---|
38 | #else |
---|
39 | // Unwind the inner loop, five elements at a time. |
---|
40 | int leftover = length() % 5; |
---|
41 | |
---|
42 | int i=0; |
---|
43 | for (; i < leftover; ++i) |
---|
44 | P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i)); |
---|
45 | |
---|
46 | for (; i < length(); i += 5) |
---|
47 | { |
---|
48 | P_updater::update(vector_(index_(i)), expr._bz_fastAccess(i)); |
---|
49 | P_updater::update(vector_(index_(i+1)), expr._bz_fastAccess(i+1)); |
---|
50 | P_updater::update(vector_(index_(i+2)), expr._bz_fastAccess(i+2)); |
---|
51 | P_updater::update(vector_(index_(i+3)), expr._bz_fastAccess(i+3)); |
---|
52 | P_updater::update(vector_(index_(i+4)), expr._bz_fastAccess(i+4)); |
---|
53 | } |
---|
54 | #endif |
---|
55 | } |
---|
56 | else { |
---|
57 | // Not all unit strides -- have to access all the vector elements |
---|
58 | // as data_[i*stride_], which is slower. |
---|
59 | for (int i=0; i < length(); ++i) |
---|
60 | P_updater::update(vector_[index_[i]], expr[i]); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | template<typename P_numtype> template<typename P_expr> |
---|
65 | inline VectorPick<P_numtype>& |
---|
66 | VectorPick<P_numtype>::operator=(_bz_VecExpr<P_expr> expr) |
---|
67 | { |
---|
68 | BZPRECONDITION(expr.length(length()) == length()); |
---|
69 | |
---|
70 | // If all vectors in the expression, plus the vector to which the |
---|
71 | // result is being assigned have unit stride, then avoid stride |
---|
72 | // calculations. |
---|
73 | if (_bz_hasFastAccess() && expr._bz_hasFastAccess()) |
---|
74 | { |
---|
75 | #ifndef BZ_PARTIAL_LOOP_UNROLL |
---|
76 | for (int i=0; i < length(); ++i) |
---|
77 | (*this)(i) = expr._bz_fastAccess(i); |
---|
78 | #else |
---|
79 | // Unwind the inner loop, five elements at a time. |
---|
80 | int leftover = length() % 5; |
---|
81 | |
---|
82 | int i=0; |
---|
83 | for (; i < leftover; ++i) |
---|
84 | (*this)(i) = expr._bz_fastAccess(i); |
---|
85 | |
---|
86 | for (; i < length(); i += 5) |
---|
87 | { |
---|
88 | (*this)(i) = expr._bz_fastAccess(i); |
---|
89 | (*this)(i+1) = expr._bz_fastAccess(i+1); |
---|
90 | (*this)(i+2) = expr._bz_fastAccess(i+2); |
---|
91 | (*this)(i+3) = expr._bz_fastAccess(i+3); |
---|
92 | (*this)(i+4) = expr._bz_fastAccess(i+4); |
---|
93 | } |
---|
94 | #endif |
---|
95 | } |
---|
96 | else { |
---|
97 | // Not all unit strides -- have to access all the vector elements |
---|
98 | // as data_[i*stride_], which is slower. |
---|
99 | for (int i=0; i < length(); ++i) |
---|
100 | (*this)[i] = expr[i]; |
---|
101 | } |
---|
102 | return *this; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | template<typename P_numtype> template<typename P_expr> |
---|
107 | inline VectorPick<P_numtype>& |
---|
108 | VectorPick<P_numtype>::operator+=(_bz_VecExpr<P_expr> expr) |
---|
109 | { |
---|
110 | _bz_assign(expr, _bz_plus_update<P_numtype, |
---|
111 | _bz_typename P_expr::T_numtype>()); |
---|
112 | return *this; |
---|
113 | } |
---|
114 | |
---|
115 | template<typename P_numtype> template<typename P_expr> |
---|
116 | inline VectorPick<P_numtype>& |
---|
117 | VectorPick<P_numtype>::operator-=(_bz_VecExpr<P_expr> expr) |
---|
118 | { |
---|
119 | _bz_assign(expr, _bz_minus_update<P_numtype, |
---|
120 | _bz_typename P_expr::T_numtype>()); |
---|
121 | return *this; |
---|
122 | } |
---|
123 | |
---|
124 | template<typename P_numtype> template<typename P_expr> |
---|
125 | inline VectorPick<P_numtype>& |
---|
126 | VectorPick<P_numtype>::operator*=(_bz_VecExpr<P_expr> expr) |
---|
127 | { |
---|
128 | _bz_assign(expr, _bz_multiply_update<P_numtype, |
---|
129 | _bz_typename P_expr::T_numtype>()); |
---|
130 | return *this; |
---|
131 | } |
---|
132 | |
---|
133 | template<typename P_numtype> template<typename P_expr> |
---|
134 | inline VectorPick<P_numtype>& |
---|
135 | VectorPick<P_numtype>::operator/=(_bz_VecExpr<P_expr> expr) |
---|
136 | { |
---|
137 | _bz_assign(expr, _bz_divide_update<P_numtype, |
---|
138 | _bz_typename P_expr::T_numtype>()); |
---|
139 | return *this; |
---|
140 | } |
---|
141 | |
---|
142 | template<typename P_numtype> template<typename P_expr> |
---|
143 | inline VectorPick<P_numtype>& |
---|
144 | VectorPick<P_numtype>::operator%=(_bz_VecExpr<P_expr> expr) |
---|
145 | { |
---|
146 | _bz_assign(expr, _bz_mod_update<P_numtype, |
---|
147 | _bz_typename P_expr::T_numtype>()); |
---|
148 | return *this; |
---|
149 | } |
---|
150 | |
---|
151 | template<typename P_numtype> template<typename P_expr> |
---|
152 | inline VectorPick<P_numtype>& |
---|
153 | VectorPick<P_numtype>::operator^=(_bz_VecExpr<P_expr> expr) |
---|
154 | { |
---|
155 | _bz_assign(expr, _bz_xor_update<P_numtype, |
---|
156 | _bz_typename P_expr::T_numtype>()); |
---|
157 | return *this; |
---|
158 | } |
---|
159 | |
---|
160 | template<typename P_numtype> template<typename P_expr> |
---|
161 | inline VectorPick<P_numtype>& |
---|
162 | VectorPick<P_numtype>::operator&=(_bz_VecExpr<P_expr> expr) |
---|
163 | { |
---|
164 | _bz_assign(expr, _bz_bitand_update<P_numtype, |
---|
165 | _bz_typename P_expr::T_numtype>()); |
---|
166 | return *this; |
---|
167 | } |
---|
168 | |
---|
169 | template<typename P_numtype> template<typename P_expr> |
---|
170 | inline VectorPick<P_numtype>& |
---|
171 | VectorPick<P_numtype>::operator|=(_bz_VecExpr<P_expr> expr) |
---|
172 | { |
---|
173 | _bz_assign(expr, _bz_bitor_update<P_numtype, |
---|
174 | _bz_typename P_expr::T_numtype>()); |
---|
175 | return *this; |
---|
176 | } |
---|
177 | |
---|
178 | template<typename P_numtype> template<typename P_expr> |
---|
179 | inline VectorPick<P_numtype>& |
---|
180 | VectorPick<P_numtype>::operator>>=(_bz_VecExpr<P_expr> expr) |
---|
181 | { |
---|
182 | _bz_assign(expr, _bz_shiftr_update<P_numtype, |
---|
183 | _bz_typename P_expr::T_numtype>()); |
---|
184 | return *this; |
---|
185 | } |
---|
186 | |
---|
187 | template<typename P_numtype> template<typename P_expr> |
---|
188 | inline VectorPick<P_numtype>& |
---|
189 | VectorPick<P_numtype>::operator<<=(_bz_VecExpr<P_expr> expr) |
---|
190 | { |
---|
191 | _bz_assign(expr, _bz_shiftl_update<P_numtype, |
---|
192 | _bz_typename P_expr::T_numtype>()); |
---|
193 | return *this; |
---|
194 | } |
---|
195 | |
---|
196 | /***************************************************************************** |
---|
197 | * Assignment operators with scalar operand |
---|
198 | */ |
---|
199 | |
---|
200 | template<typename P_numtype> |
---|
201 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(P_numtype x) |
---|
202 | { |
---|
203 | typedef _bz_VecExprConstant<P_numtype> T_expr; |
---|
204 | (*this) = _bz_VecExpr<T_expr>(T_expr(x)); |
---|
205 | return *this; |
---|
206 | } |
---|
207 | |
---|
208 | template<typename P_numtype> |
---|
209 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(P_numtype x) |
---|
210 | { |
---|
211 | typedef _bz_VecExprConstant<P_numtype> T_expr; |
---|
212 | (*this) += _bz_VecExpr<T_expr>(T_expr(x)); |
---|
213 | return *this; |
---|
214 | } |
---|
215 | |
---|
216 | template<typename P_numtype> |
---|
217 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(P_numtype x) |
---|
218 | { |
---|
219 | typedef _bz_VecExprConstant<P_numtype> T_expr; |
---|
220 | (*this) -= _bz_VecExpr<T_expr>(T_expr(x)); |
---|
221 | return *this; |
---|
222 | } |
---|
223 | |
---|
224 | template<typename 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<typename 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<typename 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<typename 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<typename 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<typename 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<typename P_numtype> |
---|
273 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(int x) |
---|
274 | { |
---|
275 | typedef _bz_VecExprConstant<int> T_expr; |
---|
276 | (*this) >>= _bz_VecExpr<T_expr>(T_expr(x)); |
---|
277 | return *this; |
---|
278 | } |
---|
279 | |
---|
280 | template<typename P_numtype> |
---|
281 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(int 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 | /***************************************************************************** |
---|
289 | * Assignment operators with vector operand |
---|
290 | */ |
---|
291 | |
---|
292 | template<typename P_numtype> template<typename P_numtype2> |
---|
293 | inline VectorPick<P_numtype>& |
---|
294 | VectorPick<P_numtype>::operator=(const Vector<P_numtype2>& x) |
---|
295 | { |
---|
296 | (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.beginFast()); |
---|
297 | return *this; |
---|
298 | } |
---|
299 | |
---|
300 | template<typename P_numtype> template<typename P_numtype2> |
---|
301 | inline VectorPick<P_numtype>& |
---|
302 | VectorPick<P_numtype>::operator+=(const Vector<P_numtype2>& x) |
---|
303 | { |
---|
304 | (*this) += _bz_VecExpr<VectorIterConst<P_numtype2> >(x.beginFast()); |
---|
305 | return *this; |
---|
306 | } |
---|
307 | |
---|
308 | template<typename P_numtype> template<typename P_numtype2> |
---|
309 | inline VectorPick<P_numtype>& |
---|
310 | VectorPick<P_numtype>::operator-=(const Vector<P_numtype2>& x) |
---|
311 | { |
---|
312 | (*this) -= _bz_VecExpr<VectorIterConst<P_numtype2> >(x.beginFast()); |
---|
313 | return *this; |
---|
314 | } |
---|
315 | |
---|
316 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
321 | return *this; |
---|
322 | } |
---|
323 | |
---|
324 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
329 | return *this; |
---|
330 | } |
---|
331 | |
---|
332 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
337 | return *this; |
---|
338 | } |
---|
339 | |
---|
340 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
345 | return *this; |
---|
346 | } |
---|
347 | |
---|
348 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
353 | return *this; |
---|
354 | } |
---|
355 | |
---|
356 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
361 | return *this; |
---|
362 | } |
---|
363 | |
---|
364 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
369 | return *this; |
---|
370 | } |
---|
371 | |
---|
372 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
377 | return *this; |
---|
378 | } |
---|
379 | |
---|
380 | /***************************************************************************** |
---|
381 | * Assignment operators with Range operand |
---|
382 | */ |
---|
383 | |
---|
384 | template<typename P_numtype> |
---|
385 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(Range r) |
---|
386 | { |
---|
387 | (*this) = _bz_VecExpr<Range>(r); |
---|
388 | return *this; |
---|
389 | } |
---|
390 | |
---|
391 | template<typename P_numtype> |
---|
392 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(Range r) |
---|
393 | { |
---|
394 | (*this) += _bz_VecExpr<Range>(r); |
---|
395 | return *this; |
---|
396 | } |
---|
397 | |
---|
398 | template<typename P_numtype> |
---|
399 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(Range r) |
---|
400 | { |
---|
401 | (*this) -= _bz_VecExpr<Range>(r); |
---|
402 | return *this; |
---|
403 | } |
---|
404 | |
---|
405 | template<typename P_numtype> |
---|
406 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(Range r) |
---|
407 | { |
---|
408 | (*this) *= _bz_VecExpr<Range>(r); |
---|
409 | return *this; |
---|
410 | } |
---|
411 | |
---|
412 | template<typename P_numtype> |
---|
413 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(Range r) |
---|
414 | { |
---|
415 | (*this) /= _bz_VecExpr<Range>(r); |
---|
416 | return *this; |
---|
417 | } |
---|
418 | |
---|
419 | template<typename P_numtype> |
---|
420 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator%=(Range r) |
---|
421 | { |
---|
422 | (*this) %= _bz_VecExpr<Range>(r); |
---|
423 | return *this; |
---|
424 | } |
---|
425 | |
---|
426 | template<typename P_numtype> |
---|
427 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator^=(Range r) |
---|
428 | { |
---|
429 | (*this) ^= _bz_VecExpr<Range>(r); |
---|
430 | return *this; |
---|
431 | } |
---|
432 | |
---|
433 | template<typename P_numtype> |
---|
434 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator&=(Range r) |
---|
435 | { |
---|
436 | (*this) &= _bz_VecExpr<Range>(r); |
---|
437 | return *this; |
---|
438 | } |
---|
439 | |
---|
440 | template<typename P_numtype> |
---|
441 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator|=(Range r) |
---|
442 | { |
---|
443 | (*this) |= _bz_VecExpr<Range>(r); |
---|
444 | return *this; |
---|
445 | } |
---|
446 | |
---|
447 | template<typename P_numtype> |
---|
448 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator>>=(Range r) |
---|
449 | { |
---|
450 | (*this) >>= _bz_VecExpr<Range>(r); |
---|
451 | return *this; |
---|
452 | } |
---|
453 | |
---|
454 | template<typename P_numtype> |
---|
455 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator<<=(Range r) |
---|
456 | { |
---|
457 | (*this) <<= _bz_VecExpr<Range>(r); |
---|
458 | return *this; |
---|
459 | } |
---|
460 | |
---|
461 | /***************************************************************************** |
---|
462 | * Assignment operators with VectorPick operand |
---|
463 | */ |
---|
464 | |
---|
465 | template<typename P_numtype> template<typename P_numtype2> |
---|
466 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator=(const |
---|
467 | VectorPick<P_numtype2>& x) |
---|
468 | { |
---|
469 | typedef VectorPickIterConst<P_numtype2> T_expr; |
---|
470 | (*this) = _bz_VecExpr<T_expr>(x.beginFast()); |
---|
471 | return *this; |
---|
472 | } |
---|
473 | |
---|
474 | template<typename P_numtype> template<typename P_numtype2> |
---|
475 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator+=(const |
---|
476 | VectorPick<P_numtype2>& x) |
---|
477 | { |
---|
478 | typedef VectorPickIterConst<P_numtype2> T_expr; |
---|
479 | (*this) += _bz_VecExpr<T_expr>(x.beginFast()); |
---|
480 | return *this; |
---|
481 | } |
---|
482 | |
---|
483 | |
---|
484 | template<typename P_numtype> template<typename P_numtype2> |
---|
485 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator-=(const |
---|
486 | VectorPick<P_numtype2>& x) |
---|
487 | { |
---|
488 | typedef VectorPickIterConst<P_numtype2> T_expr; |
---|
489 | (*this) -= _bz_VecExpr<T_expr>(x.beginFast()); |
---|
490 | return *this; |
---|
491 | } |
---|
492 | |
---|
493 | template<typename P_numtype> template<typename P_numtype2> |
---|
494 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator*=(const |
---|
495 | VectorPick<P_numtype2>& x) |
---|
496 | { |
---|
497 | typedef VectorPickIterConst<P_numtype2> T_expr; |
---|
498 | (*this) *= _bz_VecExpr<T_expr>(x.beginFast()); |
---|
499 | return *this; |
---|
500 | } |
---|
501 | |
---|
502 | template<typename P_numtype> template<typename P_numtype2> |
---|
503 | inline VectorPick<P_numtype>& VectorPick<P_numtype>::operator/=(const |
---|
504 | VectorPick<P_numtype2>& x) |
---|
505 | { |
---|
506 | typedef VectorPickIterConst<P_numtype2> T_expr; |
---|
507 | (*this) /= _bz_VecExpr<T_expr>(x.beginFast()); |
---|
508 | return *this; |
---|
509 | } |
---|
510 | |
---|
511 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
517 | return *this; |
---|
518 | } |
---|
519 | |
---|
520 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
526 | return *this; |
---|
527 | } |
---|
528 | |
---|
529 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
535 | return *this; |
---|
536 | } |
---|
537 | |
---|
538 | template<typename P_numtype> template<typename 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.beginFast()); |
---|
544 | return *this; |
---|
545 | } |
---|
546 | |
---|
547 | /***************************************************************************** |
---|
548 | * Assignment operators with Random operand |
---|
549 | */ |
---|
550 | |
---|
551 | template<typename P_numtype> template<typename P_distribution> |
---|
552 | VectorPick<P_numtype>& |
---|
553 | VectorPick<P_numtype>::operator=(Random<P_distribution>& rand) |
---|
554 | { |
---|
555 | (*this) = _bz_VecExpr<_bz_VecExprRandom<P_distribution> > |
---|
556 | (_bz_VecExprRandom<P_distribution>(rand)); |
---|
557 | return *this; |
---|
558 | } |
---|
559 | |
---|
560 | template<typename P_numtype> template<typename P_distribution> |
---|
561 | VectorPick<P_numtype>& |
---|
562 | VectorPick<P_numtype>::operator+=(Random<P_distribution>& rand) |
---|
563 | { |
---|
564 | (*this) += _bz_VecExpr<_bz_VecExprRandom<P_distribution> > |
---|
565 | (_bz_VecExprRandom<P_distribution>(rand)); |
---|
566 | return *this; |
---|
567 | } |
---|
568 | |
---|
569 | template<typename P_numtype> template<typename P_distribution> |
---|
570 | VectorPick<P_numtype>& |
---|
571 | VectorPick<P_numtype>::operator-=(Random<P_distribution>& rand) |
---|
572 | { |
---|
573 | (*this) -= _bz_VecExpr<_bz_VecExprRandom<P_distribution> > |
---|
574 | (_bz_VecExprRandom<P_distribution>(rand)); |
---|
575 | return *this; |
---|
576 | } |
---|
577 | |
---|
578 | template<typename P_numtype> template<typename 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<typename P_numtype> template<typename 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<typename P_numtype> template<typename 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<typename P_numtype> template<typename 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<typename P_numtype> template<typename 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<typename P_numtype> template<typename 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 | BZ_NAMESPACE_END |
---|
633 | |
---|
634 | #endif // BZ_VECPICK_CC |
---|