TinyVectorExpression.hxx
1 #ifndef SELDON_FILE_TINY_VECTOR_EXPRESSION_HXX
2 
3 namespace Seldon
4 {
5 
7  template<class T, int m, class E>
9  {
10  public:
11  const T operator()(int) const;
12 
13  inline operator E&() { return static_cast<E&>(*this); }
14  inline operator E const&() const { return static_cast<const E&>(*this); }
15 
16  };
17 
18 
20  template<class T, int m, class E1, class E2>
21  class TinyVectorDifference : public TinyVectorExpression<T, m, TinyVectorDifference<T, m, E1, E2> >
22  {
23  const E1& u_;
24  const E2& v_;
25 
26  public:
27  template<class T1, class T2>
29 
30  const T operator()(int) const;
31 
32  };
33 
34 
36  template<class T, int m, class E1, class E2>
37  class TinyVectorSum : public TinyVectorExpression<T, m, TinyVectorSum<T, m, E1, E2> >
38  {
39  const E1& u_;
40  const E2& v_;
41 
42  public:
43  template<class T1, class T2>
45 
46  const T operator()(int) const;
47 
48  };
49 
50 
52  template<class T, int m, class E1, class E2>
53  class TinyVectorProduct : public TinyVectorExpression<T, m, TinyVectorProduct<T, m, E1, E2> >
54  {
55  const E1& u_;
56  const E2& v_;
57 
58  public:
59  template<class T1, class T2>
61 
62  const T operator()(int) const;
63 
64  };
65 
66 
68  template<class T, int m, class E1, class E2>
69  class TinyVectorDivision : public TinyVectorExpression<T, m, TinyVectorDivision<T, m, E1, E2> >
70  {
71  const E1& u_;
72  const E2& v_;
73 
74  public:
75  template<class T1, class T2>
77 
78  const T operator()(int) const;
79 
80  };
81 
82 
84  template<class T, int m, class T0, class E>
85  class TinyVectorScaled : public TinyVectorExpression<T, m, TinyVectorScaled<T, m, T0, E> >
86  {
87  const T0 alpha_;
88  const E& u_;
89 
90  public:
91  template<class T1>
93 
94  const T operator()(int) const;
95 
96  };
97 
98 
100  template<class T, int m, class T0, class E>
101  class TinyVectorScalDiv : public TinyVectorExpression<T, m, TinyVectorScalDiv<T, m, T0, E> >
102  {
103  const T0 alpha_;
104  const E& u_;
105 
106  public:
107  template<class T1>
109 
110  const T operator()(int) const;
111 
112  };
113 
114 
116  template<class T, int m, class T0, class E>
117  class TinyVectorScalSum : public TinyVectorExpression<T, m, TinyVectorScalSum<T, m, T0, E> >
118  {
119  const T0 alpha_;
120  const E& u_;
121 
122  public:
123  template<class T1>
125 
126  const T operator()(int) const;
127 
128  };
129 
130 
132  template<class T, int m, class T0, class E>
133  class TinyVectorScalDiff : public TinyVectorExpression<T, m, TinyVectorScalDiff<T, m, T0, E> >
134  {
135  const T0 alpha_;
136  const E& u_;
137 
138  public:
139  template<class T1>
141 
142  const T operator()(int) const;
143 
144  };
145 
146 
148  template<class T, int m, class E>
149  class TinyVectorOpposite : public TinyVectorExpression<T, m, TinyVectorOpposite<T, m, E> >
150  {
151  const E& u_;
152 
153  public:
155 
156  const T operator()(int) const;
157 
158  };
159 
160 
161  /*************
162  * Operators *
163  *************/
164 
165 
166  template<class T, int m, class E1, class E2>
170 
171  template<class T, int m, class E1, class E2>
172  const TinyVectorSum<complex<T>, m, E1, E2>
173  operator +(const TinyVectorExpression<complex<T>, m, E1>& u,
175 
176  template<class T, int m, class E1, class E2>
177  const TinyVectorSum<complex<T>, m, E1, E2>
179  const TinyVectorExpression<complex<T>, m, E2>& v);
180 
181  template<class T, int m, class E1, class E2>
185 
186  template<class T, int m, class E1, class E2>
187  inline const TinyVectorDifference<complex<T>, m, E1, E2>
188  operator -(const TinyVectorExpression<complex<T>, m, E1>& u,
190 
191  template<class T, int m, class E1, class E2>
192  const TinyVectorDifference<complex<T>, m, E1, E2>
194  const TinyVectorExpression<complex<T>, m, E2>& v);
195 
196  template<class T, int m, class E1, class E2>
200 
201  template<class T, int m, class E1, class E2>
202  const TinyVectorProduct<complex<T>, m, E1, E2>
203  operator *(const TinyVectorExpression<complex<T>, m, E1>& u,
205 
206  template<class T, int m, class E1, class E2>
207  const TinyVectorProduct<complex<T>, m, E1, E2>
209  const TinyVectorExpression<complex<T>, m, E2>& v);
210 
211  template<class T, int m, class E1, class E2>
215 
216  template<class T, int m, class E1, class E2>
217  const TinyVectorDivision<complex<T>, m, E1, E2>
218  operator /(const TinyVectorExpression<complex<T>, m, E1>& u,
220 
221  template<class T, int m, class E1, class E2>
222  const TinyVectorDivision<complex<T>, m, E1, E2>
224  const TinyVectorExpression<complex<T>, m, E2>& v);
225 
226  template<class T, int m, class E>
227  const TinyVectorScaled<T, m, T, E> operator *(const T& alpha,
229 
230  template<class T, int m, class E>
231  const TinyVectorScaled<complex<T>, m, complex<T>, E>
232  operator *(const complex<T>& alpha,
234 
235  template<class T, int m, class E>
236  const TinyVectorScaled<complex<T>, m, T, E>
237  operator *(const T& alpha,
238  const TinyVectorExpression<complex<T>, m, E>& u);
239 
240  template<class T, int m, class E>
242  const T& alpha);
243 
244  template<class T, int m, class E>
245  const TinyVectorScaled<complex<T>, m, complex<T>, E>
247  const complex<T>& alpha);
248 
249  template<class T, int m, class E>
250  const TinyVectorScaled<complex<T>, m, T, E>
251  operator *(const TinyVectorExpression<complex<T>, m, E>& u,
252  const T& alpha);
253 
254  template<class T, int m, class E>
255  const TinyVectorScalDiv<T, m, T, E> operator /(const T& alpha,
257 
258  template<class T, int m, class E>
259  const TinyVectorScalDiv<complex<T>, m, complex<T>, E>
260  operator /(const complex<T>& alpha,
262 
263  template<class T, int m, class E>
264  const TinyVectorScalDiv<complex<T>, m, T, E>
265  operator /(const T& alpha,
266  const TinyVectorExpression<complex<T>, m, E>& u);
267 
268  template<class T, int m, class E>
270  const T& alpha);
271 
272  template<class T, int m, class E>
273  const TinyVectorScaled<complex<T>, m, complex<T>, E>
275  const complex<T>& alpha);
276 
277  template<class T, int m, class E>
278  const TinyVectorScaled<complex<T>, m, T, E>
279  operator /(const TinyVectorExpression<complex<T>, m, E>& u,
280  const T& alpha);
281 
282  template<class T, int m, class E>
283  const TinyVectorScalSum<T, m, T, E> operator +(const T& alpha,
285 
286  template<class T, int m, class E>
287  const TinyVectorScalSum<complex<T>, m, complex<T>, E>
288  operator +(const complex<T>& alpha,
290 
291  template<class T, int m, class E>
292  const TinyVectorScalSum<complex<T>, m, T, E>
293  operator +(const T& alpha,
294  const TinyVectorExpression<complex<T>, m, E>& u);
295 
296  template<class T, int m, class E>
298  const T& alpha);
299 
300  template<class T, int m, class E>
301  const TinyVectorScalSum<complex<T>, m, complex<T>, E>
303  const complex<T>& alpha);
304 
305  template<class T, int m, class E>
306  const TinyVectorScalSum<complex<T>, m, T, E>
307  operator +(const TinyVectorExpression<complex<T>, m, E>& u,
308  const T& alpha);
309 
310  template<class T, int m, class E>
312  const T& alpha);
313 
314  template<class T, int m, class E>
315  const TinyVectorScalSum<complex<T>, m, complex<T>, E>
317  const complex<T>& alpha);
318 
319  template<class T, int m, class E>
320  const TinyVectorScalSum<complex<T>, m, T, E>
321  operator -(const TinyVectorExpression<complex<T>, m, E>& u,
322  const T& alpha);
323 
324  template<class T, int m, class E>
325  const TinyVectorScalDiff<T, m, T, E> operator -(const T& alpha,
327 
328  template<class T, int m, class E>
329  const TinyVectorScalDiff<complex<T>, m, complex<T>, E>
330  operator -(const complex<T>& alpha,
332 
333  template<class T, int m, class E>
334  const TinyVectorScalDiff<complex<T>, m, T, E>
335  operator -(const T& alpha,
336  const TinyVectorExpression<complex<T>, m, E>& u);
337 
338  template<class T, int m, class E>
340 
341 }
342 
343 #define SELDON_FILE_TINY_VECTOR_EXPRESSION_HXX
344 #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