34 #ifndef __H__UG__LIB_ALGEBRA__TEMPLATE_EXPRESSIONS__
35 #define __H__UG__LIB_ALGEBRA__TEMPLATE_EXPRESSIONS__
80 const A&
T()
const {
return a; }
94 const A&
cast()
const {
return static_cast<const A&
>(*this); }
150 template<
typename L,
typename R>
164 static inline bool is_add() {
return true; }
169 static bool inline is_add() {
return false; }
176 template<
typename L,
typename operation,
typename R>
185 static inline bool is_add() {
return operation::is_add(); }
207 template<
typename L,
typename R>
214 template<
typename L,
typename R>
222 template<
typename L,
typename R>
231 #define MAKE_TEMPLATE_OPERATORS_VECTOR(VECTOR_TYPE) \
232 AlphaVec_Expression<VECTOR_TYPE> operator * (double d, const VECTOR_TYPE &r) \
234 return AlphaVec_Expression<VECTOR_TYPE> (d, r); \
236 template<typename L> \
237 AlphaMatVec_X_Expression<L, operation_add, VECTOR_TYPE> operator + (const L &l, const VECTOR_TYPE &r) \
239 return AlphaMatVec_X_Expression<L, operation_add, VECTOR_TYPE > (l, r); \
241 template<typename L> \
242 AlphaMatVec_X_Expression<L, operation_sub, VECTOR_TYPE> operator - (const L &l, const VECTOR_TYPE &r) \
244 return AlphaMatVec_X_Expression<L, operation_sub, VECTOR_TYPE > (l, r); \
248 #define MAKE_TEMPLATE_OPERATORS_VECTOR2(TEMPLATE_DEFINITION, VECTOR_TYPE) \
249 template<TEMPLATE_DEFINITION> \
250 AlphaVec_Expression<VECTOR_TYPE> operator * (double d, const VECTOR_TYPE &r) \
252 return AlphaVec_Expression<VECTOR_TYPE> (d, r); \
254 template<typename L, TEMPLATE_DEFINITION> \
255 AlphaMatVec_X_Expression<L, operation_add, VECTOR_TYPE> operator + (const L &l, const VECTOR_TYPE &r) \
257 return AlphaMatVec_X_Expression<L, operation_add, VECTOR_TYPE > (l, r); \
259 template<typename L, TEMPLATE_DEFINITION> \
260 AlphaMatVec_X_Expression<L, operation_sub, VECTOR_TYPE> operator - (const L &l, const VECTOR_TYPE &r) \
262 return AlphaMatVec_X_Expression<L, operation_sub, VECTOR_TYPE > (l, r); \
268 #define MAKE_TEMPLATE_OPERATORS_MATRIX(MATRIX_TYPE) \
269 AlphaMat_Expression <MATRIX_TYPE> operator * (double d, const MATRIX_TYPE &r) \
271 return AlphaMat_Expression <MATRIX_TYPE> (d, r.cast()); \
273 template<typename R> \
274 MatVec_Expression<MATRIX_TYPE, R> operator * (const MATRIX_TYPE &l, const R &r) \
276 return MatVec_Expression<MATRIX_TYPE, R> (1.0, l, r); \
281 #define MAKE_TEMPLATE_OPERATORS_MATRIX2(TEMPLATE_DEFINITION, MATRIX_TYPE) \
282 template<TEMPLATE_DEFINITION> \
283 AlphaMat_Expression <MATRIX_TYPE> operator * (double d, const MATRIX_TYPE &r) \
285 return AlphaMat_Expression <MATRIX_TYPE> (d, r.cast()); \
287 template<TEMPLATE_DEFINITION, typename R> \
288 MatVec_Expression<MATRIX_TYPE, R> operator * (const MATRIX_TYPE &l, const R &r) \
290 return MatVec_Expression<MATRIX_TYPE, R> (1.0, l, r); \
Definition: template_expressions.h:193
AlphaMat_Expression(double d, const R &r_)
Definition: template_expressions.h:197
const R & r
Definition: template_expressions.h:196
double alpha
Definition: template_expressions.h:195
Definition: template_expressions.h:178
static bool is_add()
Definition: template_expressions.h:185
const R & r
Definition: template_expressions.h:181
const L & l
Definition: template_expressions.h:180
AlphaMatVec_X_Expression(const L &l_, const R &r_)
Definition: template_expressions.h:182
Definition: template_expressions.h:106
double alpha
Definition: template_expressions.h:108
const R & r
Definition: template_expressions.h:109
AlphaVec_Expression(double alpha_, const R &r_)
Definition: template_expressions.h:110
Definition: template_expressions.h:152
const R & r
Definition: template_expressions.h:156
const L & l
Definition: template_expressions.h:155
MatVec_Expression(double alpha_, const L &l_, const R &r_)
Definition: template_expressions.h:157
double alpha
Definition: template_expressions.h:154
Definition: template_expressions.h:91
const TRANSPOSED< TE_AMV_X< A > > T() const
Definition: template_expressions.h:95
const A & cast() const
cast this class down to original class A.
Definition: template_expressions.h:94
this helper class is a transposed of class A
Definition: template_expressions.h:76
TRANSPOSED(const A &a_)
Definition: template_expressions.h:78
const A & a
Definition: template_expressions.h:82
const A & T() const
get untransposed original class A.
Definition: template_expressions.h:80
MatVec_Expression< L, R > operator*(const AlphaMat_Expression< L > &l, const R &r)
create a MatVec_Expression by (alpha*MATRIX) * VECTOR
Definition: template_expressions.h:223
AlphaMatVec_X_Expression< L, operation_sub, R > operator-(const TE_AMV_X< L > &l, const TE_AMV_X< R > &r)
create AlphaMatVec_X_Expression<L, operation_minus, R> by conjunction of TE_AMV_X<L> + TE_AMV_X<R>
Definition: template_expressions.h:215
const T & getVector(const T &t)
Definition: template_expressions.h:123
double getScaling(const T &t)
Definition: template_expressions.h:117
AlphaMatVec_X_Expression< L, operation_add, R > operator+(const TE_AMV_X< L > &l, const TE_AMV_X< R > &r)
create AlphaMatVec_X_Expression<L, operation_add, R> by conjunction of TE_AMV_X<L> + TE_AMV_X<R>
Definition: template_expressions.h:208
Definition: template_expressions.h:163
static bool is_add()
Definition: template_expressions.h:164
Definition: template_expressions.h:168
static bool is_add()
Definition: template_expressions.h:169