VectorExpression.hxx
1 #ifndef SELDON_FILE_VECTOR_EXPRESSION_HXX
2 
3 namespace Seldon
4 {
5 
7  template<class T, class E>
9  {
10  public:
11  long GetSize() const;
12  const T operator()(long) const;
13 
14  inline operator E&() { return static_cast<E&>(*this); }
15  inline operator E const&() const { return static_cast<const E&>(*this); }
16 
17  };
18 
19 
21  template<class T, class E1, class E2>
22  class VectorDifference : public VectorExpression<T, VectorDifference<T, E1, E2> >
23  {
24  const E1& u_;
25  const E2& v_;
26 
27  public:
28  template<class T1, class T2>
30 
31  long GetSize() const;
32  const T operator()(long) const;
33 
34  };
35 
36 
38  template<class T, class E1, class E2>
39  class VectorSum : public VectorExpression<T, VectorSum<T, E1, E2> >
40  {
41  const E1& u_;
42  const E2& v_;
43 
44  public:
45  template<class T1, class T2>
47 
48  long GetSize() const;
49  const T operator()(long) const;
50 
51  };
52 
53 
55  template<class T, class E1, class E2>
56  class VectorProduct : public VectorExpression<T, VectorProduct<T, E1, E2> >
57  {
58  const E1& u_;
59  const E2& v_;
60 
61  public:
62  template<class T1, class T2>
64 
65  long GetSize() const;
66  const T operator()(long) const;
67 
68  };
69 
70 
72  template<class T, class E1, class E2>
73  class VectorDivision : public VectorExpression<T, VectorDivision<T, E1, E2> >
74  {
75  const E1& u_;
76  const E2& v_;
77 
78  public:
79  template<class T1, class T2>
81 
82  long GetSize() const;
83  const T operator()(long) const;
84 
85  };
86 
87 
89  template<class T, class T0, class E>
90  class VectorScaled : public VectorExpression<T, VectorScaled<T, T0, E> >
91  {
92  const T0 alpha_;
93  const E& u_;
94 
95  public:
96  template<class T1>
97  VectorScaled(const T0&, const VectorExpression<T1, E>&);
98 
99  long GetSize() const;
100  const T operator()(long) const;
101 
102  };
103 
104 
106  template<class T, class T0, class E>
107  class VectorScalDiv : public VectorExpression<T, VectorScalDiv<T, T0, E> >
108  {
109  const T0 alpha_;
110  const E& u_;
111 
112  public:
113  template<class T1>
114  VectorScalDiv(const T0&, const VectorExpression<T1, E>&);
115 
116  long GetSize() const;
117  const T operator()(long) const;
118 
119  };
120 
121 
123  template<class T, class T0, class E>
124  class VectorScalSum : public VectorExpression<T, VectorScalSum<T, T0, E> >
125  {
126  const T0 alpha_;
127  const E& u_;
128 
129  public:
130  template<class T1>
131  VectorScalSum(const T0&, const VectorExpression<T1, E>&);
132 
133  long GetSize() const;
134  const T operator()(long) const;
135 
136  };
137 
138 
140  template<class T, class T0, class E>
141  class VectorScalDiff : public VectorExpression<T, VectorScalDiff<T, T0, E> >
142  {
143  const T0 alpha_;
144  const E& u_;
145 
146  public:
147  template<class T1>
148  VectorScalDiff(const T0&, const VectorExpression<T1, E>&);
149 
150  long GetSize() const;
151  const T operator()(long) const;
152 
153  };
154 
155 
157  template<class T, class E>
158  class VectorOpposite : public VectorExpression<T, VectorOpposite<T, E> >
159  {
160  const E& u_;
161 
162  public:
164 
165  long GetSize() const;
166  const T operator()(long) const;
167 
168  };
169 
170 
171  /*************
172  * Operators *
173  *************/
174 
175 
176  template<class T, class E1, class E2>
178 
179  template<class T, class E1, class E2>
180  const VectorSum<complex<T>, E1, E2> operator+(const VectorExpression<complex<T>, E1>&,
181  const VectorExpression<T, E2>&);
182 
183  template<class T, class E1, class E2>
185  const VectorExpression<complex<T>, E2>&);
186 
187 
188  template<class T, class E1, class E2>
190 
191  template<class T, class E1, class E2>
192  const VectorDifference<complex<T>, E1, E2> operator-(const VectorExpression<complex<T>, E1>&,
193  const VectorExpression<T, E2>&);
194 
195  template<class T, class E1, class E2>
197  const VectorExpression<complex<T>, E2>&);
198 
199 
200  template<class T, class E1, class E2>
202 
203  template<class T, class E1, class E2>
204  const VectorProduct<complex<T>, E1, E2> operator*(const VectorExpression<complex<T>, E1>&,
205  const VectorExpression<T, E2>&);
206 
207  template<class T, class E1, class E2>
209  const VectorExpression<complex<T>, E2>&);
210 
211 
212  template<class T, class E1, class E2>
214 
215  template<class T, class E1, class E2>
216  const VectorDivision<complex<T>, E1, E2> operator/(const VectorExpression<complex<T>, E1>&,
217  const VectorExpression<T, E2>&);
218 
219  template<class T, class E1, class E2>
221  const VectorExpression<complex<T>, E2>&);
222 
223 
224  template<class T, class E>
226 
227  template<class T, class E>
228  const VectorScaled<complex<T>, complex<T>, E> operator*(const complex<T>&,
229  const VectorExpression<T, E>&);
230 
231  template<class T, class E>
232  const VectorScaled<complex<T>, T, E> operator*(const T&,
233  const VectorExpression<complex<T>, E>&);
234 
235  template<class T, class E>
237 
238  template<class T, class E>
239  const VectorScaled<complex<T>, complex<T>, E> operator*(const VectorExpression<T, E>&,
240  const complex<T>&);
241 
242  template<class T, class E>
243  const VectorScaled<complex<T>, T, E> operator*(const VectorExpression<complex<T>, E>&, const T&);
244 
245 
246  template<class T, class E>
248 
249  template<class T, class E>
250  const VectorScalDiv<complex<T>, complex<T>, E> operator/(const complex<T>&,
251  const VectorExpression<T, E>&);
252 
253  template<class T, class E>
254  const VectorScalDiv<complex<T>, T, E> operator/(const T&,
255  const VectorExpression<complex<T>, E>&);
256 
257  template<class T, class E>
259 
260  template<class T, class E>
261  const VectorScaled<complex<T>, complex<T>, E> operator/(const VectorExpression<T, E>&,
262  const complex<T>&);
263 
264  template<class T, class E>
265  const VectorScaled<complex<T>, T, E> operator/(const VectorExpression<complex<T>, E>&, const T&);
266 
267 
268  template<class T, class E>
270 
271  template<class T, class E>
272  const VectorScalSum<complex<T>, complex<T>, E> operator+(const complex<T>&,
273  const VectorExpression<T, E>&);
274 
275  template<class T, class E>
276  const VectorScalSum<complex<T>, T, E> operator+(const T&,
277  const VectorExpression<complex<T>, E>&);
278 
279  template<class T, class E>
281 
282  template<class T, class E>
283  const VectorScalSum<complex<T>, complex<T>, E> operator+(const VectorExpression<T, E>&,
284  const complex<T>&);
285 
286  template<class T, class E>
287  const VectorScalSum<complex<T>, T, E> operator+(const VectorExpression<complex<T>, E>&, const T&);
288 
289 
290  template<class T, class E>
292 
293  template<class T, class E>
294  const VectorScalDiff<complex<T>, complex<T>, E> operator-(const complex<T>&,
295  const VectorExpression<T, E>&);
296 
297  template<class T, class E>
298  const VectorScalDiff<complex<T>, T, E> operator-(const T&,
299  const VectorExpression<complex<T>, E>&);
300 
301  template<class T, class E>
303 
304  template<class T, class E>
305  const VectorScalSum<complex<T>, complex<T>, E> operator-(const VectorExpression<T, E>&,
306  const complex<T>&);
307 
308  template<class T, class E>
309  const VectorScalSum<complex<T>, T, E> operator-(const VectorExpression<complex<T>, E>&, const T&);
310 
311 
312  template<class T, class E>
314 
315 }
316 
317 #define SELDON_FILE_VECTOR_EXPRESSION_HXX
318 #endif
Seldon::VectorScalSum::VectorScalSum
VectorScalSum(const T0 &, const VectorExpression< T1, E > &)
Constructor alpha + u with a scalar alpha and an expression u.
Definition: VectorExpressionInline.cxx:205
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::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::VectorExpression::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:8
Seldon::VectorScalSum
Addition between a scalar and a vector.
Definition: VectorExpression.hxx:124
Seldon::VectorScaled::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:164
Seldon::VectorExpression
Expression between vectors.
Definition: VectorExpression.hxx:8
Seldon::VectorScaled::VectorScaled
VectorScaled(const T0 &, const VectorExpression< T1, E > &)
Constructor alpha * u with a scalar alpha and an expression u.
Definition: VectorExpressionInline.cxx:155
Seldon::VectorScalDiff::VectorScalDiff
VectorScalDiff(const T0 &, const VectorExpression< T1, E > &)
Constructor alpha - u with a scalar alpha and an expression u.
Definition: VectorExpressionInline.cxx:230
Seldon::VectorDivision::VectorDivision
VectorDivision(const VectorExpression< T1, E1 > &, const VectorExpression< T2, E2 > &)
Constructor u / v with two expressions u and v.
Definition: VectorExpressionInline.cxx:123
Seldon::VectorScalDiv
Division between a scalar and a vector.
Definition: VectorExpression.hxx:107
Seldon::VectorSum::operator()
const T operator()(long) const
returns the i-th element of the sum
Definition: VectorExpressionInline.cxx:81
Seldon::VectorDivision::operator()
const T operator()(long) const
returns the i-th element of the element-wise division
Definition: VectorExpressionInline.cxx:147
Seldon::VectorExpression::operator()
const T operator()(long) const
returns the element i of expression
Definition: VectorExpressionInline.cxx:16
Seldon::VectorScalDiff::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:239
Seldon::VectorDifference::GetSize
long GetSize() const
returns the size of the associated vectors
Definition: VectorExpressionInline.cxx:41
Seldon::VectorDifference::operator()
const T operator()(long) const
returns the i-th element of the difference
Definition: VectorExpressionInline.cxx:49
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::VectorSum
Sum between two expressions.
Definition: VectorExpression.hxx:39
Seldon::VectorScaled::operator()
const T operator()(long) const
returns the i-th element of alpha*u
Definition: VectorExpressionInline.cxx:172
Seldon::VectorScalDiff
Subtraction between a scalar and a vector.
Definition: VectorExpression.hxx:141
Seldon::VectorDivision
Division between two expressions (elementwise)
Definition: VectorExpression.hxx:73
Seldon::VectorScalDiff::operator()
const T operator()(long) const
returns the i-th element of alpha - u
Definition: VectorExpressionInline.cxx:247
Seldon::VectorDivision::GetSize
long GetSize() const
returns the size of the associated vectors
Definition: VectorExpressionInline.cxx:139
Seldon::VectorSum::VectorSum
VectorSum(const VectorExpression< T1, E1 > &, const VectorExpression< T2, E2 > &)
Constructor u+v with two expressions u and v.
Definition: VectorExpressionInline.cxx:57
Seldon::VectorOpposite::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:263
Seldon::VectorProduct::operator()
const T operator()(long) const
returns the i-th element of the element-wise product
Definition: VectorExpressionInline.cxx:114
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::VectorScalDiv::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:189
Seldon::VectorOpposite
Opposite of a vector.
Definition: VectorExpression.hxx:158
Seldon::VectorDifference::VectorDifference
VectorDifference(const VectorExpression< T1, E1 > &, const VectorExpression< T2, E2 > &)
Constructor u-v with two expressions u and v.
Definition: VectorExpressionInline.cxx:25
Seldon::VectorSum::GetSize
long GetSize() const
returns the size of the associated vectors
Definition: VectorExpressionInline.cxx:73
Seldon::VectorProduct::GetSize
long GetSize() const
returns the size of the associated vectors
Definition: VectorExpressionInline.cxx:106
Seldon::VectorOpposite::VectorOpposite
VectorOpposite(const VectorExpression< T, E > &)
Constructor -u with an expression u.
Definition: VectorExpressionInline.cxx:255
Seldon::VectorProduct
Product between two expressions (elementwise)
Definition: VectorExpression.hxx:56
Seldon::VectorScalDiv::VectorScalDiv
VectorScalDiv(const T0 &, const VectorExpression< T1, E > &)
Constructor alpha / u with a scalar alpha and an expression u.
Definition: VectorExpressionInline.cxx:180
Seldon::VectorProduct::VectorProduct
VectorProduct(const VectorExpression< T1, E1 > &, const VectorExpression< T2, E2 > &)
Constructor u*v with two expressions u and v.
Definition: VectorExpressionInline.cxx:90
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::VectorOpposite::operator()
const T operator()(long) const
returns the i-th element of -u
Definition: VectorExpressionInline.cxx:271
Seldon::VectorScalSum::operator()
const T operator()(long) const
returns the i-th element of alpha + u
Definition: VectorExpressionInline.cxx:222
Seldon::VectorScalDiv::operator()
const T operator()(long) const
returns the i-th element of alpha / u
Definition: VectorExpressionInline.cxx:197
Seldon::VectorScaled
Multiplication between a scalar and a vector.
Definition: VectorExpression.hxx:90
Seldon::VectorScalSum::GetSize
long GetSize() const
returns the size of the associated vector
Definition: VectorExpressionInline.cxx:214
Seldon::VectorDifference
Difference between two expressions.
Definition: VectorExpression.hxx:22