TinyVectorExpressionInline.cxx
1 #ifndef SELDON_FILE_TINY_VECTOR_EXPRESSION_INLINE_CXX
2 
3 namespace Seldon
4 {
5 
7  template<class T, int m, class E>
8  inline const T TinyVectorExpression<T, m, E>::operator()(int i) const
9  {
10  return static_cast<const E&>(*this)(i);
11  }
12 
13 
15  template<class T, int m, class E1, class E2> template<class T1, class T2>
19  : u_(u), v_(v)
20  {
21  }
22 
23 
25  template<class T, int m, class E1, class E2>
27  {
28  return u_(i) - v_(i);
29  }
30 
31 
33  template<class T, int m, class E1, class E2> template<class T1, class T2>
37  : u_(u), v_(v)
38  {
39  }
40 
41 
43  template<class T, int m, class E1, class E2>
44  inline const T TinyVectorSum<T, m, E1, E2>::operator()(int i) const
45  {
46  return u_(i) + v_(i);
47  }
48 
49 
51  template<class T, int m, class E1, class E2> template<class T1, class T2>
55  : u_(u), v_(v)
56  {
57  }
58 
59 
61  template<class T, int m, class E1, class E2>
62  inline const T TinyVectorProduct<T, m, E1, E2>::operator()(int i) const
63  {
64  return u_(i) * v_(i);
65  }
66 
67 
69  template<class T, int m, class E1, class E2> template<class T1, class T2>
73  : u_(u), v_(v)
74  {
75  }
76 
77 
79  template<class T, int m, class E1, class E2>
81  {
82  return u_(i) / v_(i);
83  }
84 
85 
87  template<class T, int m, class T0, class E> template<class T1>
90  : alpha_(alpha), u_(u)
91  {
92  }
93 
94 
96  template<class T, int m, class T0, class E>
97  inline const T TinyVectorScaled<T, m, T0, E>::operator()(int i) const
98  {
99  return alpha_*u_(i);
100  }
101 
102 
104  template<class T, int m, class T0, class E> template<class T1>
107  : alpha_(alpha), u_(u)
108  {
109  }
110 
111 
113  template<class T, int m, class T0, class E>
114  inline const T TinyVectorScalDiv<T, m, T0, E>::operator()(int i) const
115  {
116  return alpha_ / u_(i);
117  }
118 
119 
121  template<class T, int m, class T0, class E> template<class T1>
124  : alpha_(alpha), u_(u)
125  {
126  }
127 
128 
130  template<class T, int m, class T0, class E>
131  inline const T TinyVectorScalSum<T, m, T0, E>::operator()(int i) const
132  {
133  return alpha_ + u_(i);
134  }
135 
136 
138  template<class T, int m, class T0, class E> template<class T1>
141  : alpha_(alpha), u_(u)
142  {
143  }
144 
145 
147  template<class T, int m, class T0, class E>
149  {
150  return alpha_ - u_(i);
151  }
152 
153 
155  template<class T, int m, class E>
157  : u_(u)
158  {
159  }
160 
161 
163  template<class T, int m, class E>
164  inline const T TinyVectorOpposite<T, m, E>::operator()(int i) const
165  {
166  return -u_(i);
167  }
168 
169 
170  /*************
171  * Operators *
172  *************/
173 
174 
176  template<class T, int m, class E1, class E2>
177  inline const TinyVectorSum<T, m, E1, E2>
180  {
181  return TinyVectorSum<T, m, E1, E2>(u, v);
182  }
183 
184 
186  template<class T, int m, class E1, class E2>
187  inline const TinyVectorSum<complex<T>, m, E1, E2>
188  operator +(const TinyVectorExpression<complex<T>, m, E1>& u,
190  {
191  return TinyVectorSum<complex<T>, m, E1, E2>(u, v);
192  }
193 
194 
196  template<class T, int m, class E1, class E2>
197  inline const TinyVectorSum<complex<T>, m, E1, E2>
199  const TinyVectorExpression<complex<T>, m, E2>& v)
200  {
201  return TinyVectorSum<complex<T>, m, E1, E2>(u, v);
202  }
203 
204 
206  template<class T, int m, class E1, class E2>
207  inline const TinyVectorDifference<T, m, E1, E2>
210  {
212  }
213 
214 
216  template<class T, int m, class E1, class E2>
217  inline const TinyVectorDifference<complex<T>, m, E1, E2>
218  operator -(const TinyVectorExpression<complex<T>, m, E1>& u,
220  {
221  return TinyVectorDifference<complex<T>, m, E1, E2>(u, v);
222  }
223 
224 
226  template<class T, int m, class E1, class E2>
227  inline const TinyVectorDifference<complex<T>, m, E1, E2>
229  const TinyVectorExpression<complex<T>, m, E2>& v)
230  {
231  return TinyVectorDifference<complex<T>, m, E1, E2>(u, v);
232  }
233 
234 
236  template<class T, int m, class E1, class E2>
237  inline const TinyVectorProduct<T, m, E1, E2>
240  {
241  return TinyVectorProduct<T, m, E1, E2>(u, v);
242  }
243 
244 
246  template<class T, int m, class E1, class E2>
247  inline const TinyVectorProduct<complex<T>, m, E1, E2>
248  operator *(const TinyVectorExpression<complex<T>, m, E1>& u,
250  {
251  return TinyVectorProduct<complex<T>, m, E1, E2>(u, v);
252  }
253 
254 
256  template<class T, int m, class E1, class E2>
257  inline const TinyVectorProduct<complex<T>, m, E1, E2>
259  const TinyVectorExpression<complex<T>, m, E2>& v)
260  {
261  return TinyVectorProduct<complex<T>, m, E1, E2>(u, v);
262  }
263 
264 
266  template<class T, int m, class E1, class E2>
267  inline const TinyVectorDivision<T, m, E1, E2>
270  {
272  }
273 
274 
276  template<class T, int m, class E1, class E2>
277  inline const TinyVectorDivision<complex<T>, m, E1, E2>
278  operator /(const TinyVectorExpression<complex<T>, m, E1>& u,
280  {
281  return TinyVectorDivision<complex<T>, m, E1, E2>(u, v);
282  }
283 
284 
286  template<class T, int m, class E1, class E2>
287  inline const TinyVectorDivision<complex<T>, m, E1, E2>
289  const TinyVectorExpression<complex<T>, m, E2>& v)
290  {
291  return TinyVectorDivision<complex<T>, m, E1, E2>(u, v);
292  }
293 
294 
296  template<class T, int m, class E>
297  inline const TinyVectorScaled<T, m, T, E> operator *(const T& alpha,
299  {
300  return TinyVectorScaled<T, m, T, E>(alpha, u);
301  }
302 
303 
305  template<class T, int m, class E>
306  inline const TinyVectorScaled<complex<T>, m, complex<T>, E>
307  operator *(const complex<T>& alpha,
309  {
310  return TinyVectorScaled<complex<T>, m, complex<T>, E>(alpha, u);
311  }
312 
313 
315  template<class T, int m, class E>
316  inline const TinyVectorScaled<complex<T>, m, T, E>
317  operator *(const T& alpha,
318  const TinyVectorExpression<complex<T>, m, E>& u)
319  {
320  return TinyVectorScaled<complex<T>, m, T, E>(alpha, u);
321  }
322 
323 
325  template<class T, int m, class E>
327  const T& alpha)
328  {
329  return TinyVectorScaled<T, m, T, E>(alpha, u);
330  }
331 
332 
334  template<class T, int m, class E>
335  inline const TinyVectorScaled<complex<T>, m, complex<T>, E>
337  const complex<T>& alpha)
338  {
339  return TinyVectorScaled<complex<T>, m, complex<T>, E>(alpha, u);
340  }
341 
342 
344  template<class T, int m, class E>
345  inline const TinyVectorScaled<complex<T>, m, T, E>
346  operator *(const TinyVectorExpression<complex<T>, m, E>& u,
347  const T& alpha)
348  {
349  return TinyVectorScaled<complex<T>, m, T, E>(alpha, u);
350  }
351 
352 
354  template<class T, int m, class E>
355  inline const TinyVectorScalDiv<T, m, T, E> operator /(const T& alpha,
357  {
358  return TinyVectorScalDiv<T, m, T, E>(alpha, u);
359  }
360 
361 
363  template<class T, int m, class E>
364  inline const TinyVectorScalDiv<complex<T>, m, complex<T>, E>
365  operator /(const complex<T>& alpha,
367  {
368  return TinyVectorScalDiv<complex<T>, m, complex<T>, E>(alpha, u);
369  }
370 
371 
373  template<class T, int m, class E>
374  inline const TinyVectorScalDiv<complex<T>, m, T, E>
375  operator /(const T& alpha,
376  const TinyVectorExpression<complex<T>, m, E>& u)
377  {
378  return TinyVectorScalDiv<complex<T>, m, T, E>(alpha, u);
379  }
380 
381 
383  template<class T, int m, class E>
385  const T& alpha)
386  {
387  T one; SetComplexOne(one);
388  return TinyVectorScaled<T, m, T, E>(one/alpha, u);
389  }
390 
391 
393  template<class T, int m, class E>
394  inline const TinyVectorScaled<complex<T>, m, complex<T>, E>
396  const complex<T>& alpha)
397  {
398  T one; SetComplexOne(one);
399  return TinyVectorScaled<complex<T>, m, complex<T>, E>(one/alpha, u);
400  }
401 
402 
404  template<class T, int m, class E>
405  inline const TinyVectorScaled<complex<T>, m, T, E>
406  operator /(const TinyVectorExpression<complex<T>, m, E>& u,
407  const T& alpha)
408  {
409  T one; SetComplexOne(one);
410  return TinyVectorScaled<complex<T>, m, T, E>(one/alpha, u);
411  }
412 
413 
415  template<class T, int m, class E>
416  inline const TinyVectorScalSum<T, m, T, E> operator +(const T& alpha,
418  {
419  return TinyVectorScalSum<T, m, T, E>(alpha, u);
420  }
421 
422 
424  template<class T, int m, class E>
425  inline const TinyVectorScalSum<complex<T>, m, complex<T>, E>
426  operator +(const complex<T>& alpha,
428  {
429  return TinyVectorScalSum<complex<T>, m, complex<T>, E>(alpha, u);
430  }
431 
432 
434  template<class T, int m, class E>
435  inline const TinyVectorScalSum<complex<T>, m, T, E>
436  operator +(const T& alpha,
437  const TinyVectorExpression<complex<T>, m, E>& u)
438  {
439  return TinyVectorScalSum<complex<T>, m, T, E>(alpha, u);
440  }
441 
442 
444  template<class T, int m, class E>
446  const T& alpha)
447  {
448  return TinyVectorScalSum<T, m, T, E>(alpha, u);
449  }
450 
451 
453  template<class T, int m, class E>
454  inline const TinyVectorScalSum<complex<T>, m, complex<T>, E>
456  const complex<T>& alpha)
457  {
458  return TinyVectorScalSum<complex<T>, m, complex<T>, E>(alpha, u);
459  }
460 
461 
463  template<class T, int m, class E>
464  inline const TinyVectorScalSum<complex<T>, m, T, E>
465  operator +(const TinyVectorExpression<complex<T>, m, E>& u,
466  const T& alpha)
467  {
468  return TinyVectorScalSum<complex<T>, m, T, E>(alpha, u);
469  }
470 
471 
473  template<class T, int m, class E>
475  const T& alpha)
476  {
477  return TinyVectorScalSum<T, m, T, E>(-alpha, u);
478  }
479 
480 
482  template<class T, int m, class E>
483  inline const TinyVectorScalSum<complex<T>, m, complex<T>, E>
485  const complex<T>& alpha)
486  {
487  return TinyVectorScalSum<complex<T>, m, complex<T>, E>(-alpha, u);
488  }
489 
490 
492  template<class T, int m, class E>
493  inline const TinyVectorScalSum<complex<T>, m, T, E>
494  operator -(const TinyVectorExpression<complex<T>, m, E>& u,
495  const T& alpha)
496  {
497  return TinyVectorScalSum<complex<T>, m, T, E>(-alpha, u);
498  }
499 
500 
502  template<class T, int m, class E>
503  inline const TinyVectorScalDiff<T, m, T, E> operator -(const T& alpha,
505  {
506  return TinyVectorScalDiff<T, m, T, E>(alpha, u);
507  }
508 
509 
511  template<class T, int m, class E>
512  inline const TinyVectorScalDiff<complex<T>, m, complex<T>, E>
513  operator -(const complex<T>& alpha,
515  {
516  return TinyVectorScalDiff<complex<T>, m, complex<T>, E>(alpha, u);
517  }
518 
519 
521  template<class T, int m, class E>
522  inline const TinyVectorScalDiff<complex<T>, m, T, E>
523  operator -(const T& alpha,
524  const TinyVectorExpression<complex<T>, m, E>& u)
525  {
526  return TinyVectorScalDiff<complex<T>, m, T, E>(alpha, u);
527  }
528 
529 
531  template<class T, int m, class E>
533  {
534  return TinyVectorOpposite<T, m, E>(u);
535  }
536 
537 }
538 
539 #define SELDON_FILE_TINY_VECTOR_EXPRESSION_INLINE_CXX
540 #endif
Seldon::TinyVectorSum::TinyVectorSum
TinyVectorSum(const TinyVectorExpression< T1, m, E1 > &, const TinyVectorExpression< T2, m, E2 > &)
Constructor u+v with two expressions u and v.
Definition: TinyVectorExpressionInline.cxx:35
Seldon::operator*
const TinyMatrixProduct< T, m, n, E1, E2 > operator*(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns u*v element-wise
Definition: TinyMatrixExpressionInline.cxx:257
Seldon::TinyVectorProduct::operator()
const T operator()(int) const
returns the i-th element of the element-wise product
Definition: TinyVectorExpressionInline.cxx:62
Seldon::TinyVectorOpposite
Opposite of a vector.
Definition: TinyVectorExpression.hxx:149
Seldon::operator+
const TinyMatrixSum< T, m, n, E1, E2 > operator+(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns u+v
Definition: TinyMatrixExpressionInline.cxx:197
Seldon::TinyVectorProduct
Product between two expressions (elementwise)
Definition: TinyVectorExpression.hxx:53
Seldon::TinyVectorSum::operator()
const T operator()(int) const
returns the i-th element of the sum
Definition: TinyVectorExpressionInline.cxx:44
Seldon::TinyVectorExpression
Expression between vectors.
Definition: TinyVectorExpression.hxx:8
Seldon::TinyVectorScalDiff
Subtraction between a scalar and a vector.
Definition: TinyVectorExpression.hxx:133
Seldon::TinyVectorDifference::operator()
const T operator()(int) const
returns the i-th element of the difference
Definition: TinyVectorExpressionInline.cxx:26
Seldon::TinyVectorScalDiv
Division between a scalar and a vector.
Definition: TinyVectorExpression.hxx:101
Seldon::TinyVectorScalSum
Addition between a scalar and a vector.
Definition: TinyVectorExpression.hxx:117
Seldon::TinyVectorScalSum::TinyVectorScalSum
TinyVectorScalSum(const T0 &, const TinyVectorExpression< T1, m, E > &)
Constructor alpha + u with a scalar alpha and an expression u.
Definition: TinyVectorExpressionInline.cxx:122
Seldon::TinyVectorScaled::TinyVectorScaled
TinyVectorScaled(const T0 &, const TinyVectorExpression< T1, m, E > &)
Constructor alpha * u with a scalar alpha and an expression u.
Definition: TinyVectorExpressionInline.cxx:88
Seldon::TinyVectorDivision::TinyVectorDivision
TinyVectorDivision(const TinyVectorExpression< T1, m, E1 > &, const TinyVectorExpression< T2, m, E2 > &)
Constructor u / v with two expressions u and v.
Definition: TinyVectorExpressionInline.cxx:71
Seldon::TinyVectorScalDiff::TinyVectorScalDiff
TinyVectorScalDiff(const T0 &, const TinyVectorExpression< T1, m, E > &)
Constructor alpha - u with a scalar alpha and an expression u.
Definition: TinyVectorExpressionInline.cxx:139
Seldon::TinyVectorScalDiv::operator()
const T operator()(int) const
returns the i-th element of alpha / u
Definition: TinyVectorExpressionInline.cxx:114
Seldon::TinyVectorDifference::TinyVectorDifference
TinyVectorDifference(const TinyVectorExpression< T1, m, E1 > &, const TinyVectorExpression< T2, m, E2 > &)
Constructor u-v with two expressions u and v.
Definition: TinyVectorExpressionInline.cxx:17
Seldon::TinyVectorSum
Sum between two expressions.
Definition: TinyVectorExpression.hxx:37
Seldon::operator/
const TinyMatrixDivision< T, m, n, E1, E2 > operator/(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns u/v element-wise
Definition: TinyMatrixExpressionInline.cxx:287
Seldon::TinyVectorScaled::operator()
const T operator()(int) const
returns the i-th element of alpha*u
Definition: TinyVectorExpressionInline.cxx:97
Seldon::TinyVectorDivision
Division between two expressions (elementwise)
Definition: TinyVectorExpression.hxx:69
Seldon::TinyVectorScaled
Multiplication between a scalar and a vector.
Definition: TinyVectorExpression.hxx:85
Seldon::TinyVectorOpposite::TinyVectorOpposite
TinyVectorOpposite(const TinyVectorExpression< T, m, E > &)
Constructor -u with an expression u.
Definition: TinyVectorExpressionInline.cxx:156
Seldon::operator-
const TinyMatrixDifference< T, m, n, E1, E2 > operator-(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns u-v
Definition: TinyMatrixExpressionInline.cxx:227
Seldon::TinyVectorScalDiff::operator()
const T operator()(int) const
returns the i-th element of alpha - u
Definition: TinyVectorExpressionInline.cxx:148
Seldon::TinyVectorOpposite::operator()
const T operator()(int) const
returns the i-th element of -u
Definition: TinyVectorExpressionInline.cxx:164
Seldon::TinyVectorScalDiv::TinyVectorScalDiv
TinyVectorScalDiv(const T0 &, const TinyVectorExpression< T1, m, E > &)
Constructor alpha / u with a scalar alpha and an expression u.
Definition: TinyVectorExpressionInline.cxx:105
Seldon::TinyVectorDifference
Difference between two expressions.
Definition: TinyVectorExpression.hxx:21
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::TinyVectorProduct::TinyVectorProduct
TinyVectorProduct(const TinyVectorExpression< T1, m, E1 > &, const TinyVectorExpression< T2, m, E2 > &)
Constructor u*v with two expressions u and v.
Definition: TinyVectorExpressionInline.cxx:53
Seldon::TinyVectorExpression::operator()
const T operator()(int) const
returns the element i of expression
Definition: TinyVectorExpressionInline.cxx:8
Seldon::TinyVectorDivision::operator()
const T operator()(int) const
returns the i-th element of the element-wise division
Definition: TinyVectorExpressionInline.cxx:80
Seldon::TinyVectorScalSum::operator()
const T operator()(int) const
returns the i-th element of alpha + u
Definition: TinyVectorExpressionInline.cxx:131