ug4
Loading...
Searching...
No Matches
te.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 * Author: Martin Rupp
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33
34#ifndef __H__UG__LIB_ALGEBRA__TEMPLATE_EXPRESSIONS2__
35#define __H__UG__LIB_ALGEBRA__TEMPLATE_EXPRESSIONS2__
36
37//#include "blockMatrix.h"
38
39
40namespace ug{
41
47template<typename T>
49{
50public:
51 const T& cast() const {return static_cast<const T&>(*this); }
52 double scaling() const { return cast().scaling(); }
53};
54
55template<typename T>
56class TE_VecScale : public TE_AlphaVec<TE_VecScale<T> >
57{
58public:
59 typedef T vector_type;
60 double a;
61 const T& v;
62
63 double scaling() const { return a;}
64 const T &vec() const { return v; }
65
66 inline TE_VecScale(double a_, const T & v_) : a(a_), v(v_)
67 { }
68
69};
70
71template<class T>
72class TE_Vector : public TE_AlphaVec<TE_Vector<T> >
73{
74public:
75 typedef T vector_type;
76 double scaling() const { return 1.0;}
77 const T& vec() const {return static_cast<const T&>(*this); }
78};
79
80
81
83// alpha*v
84
85template<typename T>
86TE_VecScale <typename T::vector_type> operator * (double alpha, const TE_AlphaVec<T> &r)
87{
88 return TE_VecScale<typename T::vector_type> (r.scaling()*alpha, r.cast().vec());
89}
90
91template<typename T>
92TE_AlphaVec <typename T::vector_type> operator * (const TE_AlphaVec<T> &l, double alpha)
93{
94 return TE_VecScale<typename T::vector_type> (l.scaling()*alpha, l.cast().vec());
95}
96
98
102
103
104template<typename T>
106{
107public:
108 double a1;
109 const T& v1;
110 double a2;
111 const T& v2;
112 inline TE_VecAdd2(double a1_, const T& v1_, double a2_, const T& v2_)
113 : a1(a1_), v1(v1_), a2(a2_), v2(v2_) {}
114};
115
116
117template<typename T>
119{
120public:
121 double a1;
122 const T& v1;
123 double a2;
124 const T& v2;
125 double a3;
126 const T& v3;
127 inline TE_VecAdd3(double a1_, const T& v1_, double a2_, const T& v2_, double a3_, const T& v3_)
128 : a1(a1_), v1(v1_), a2(a2_), v2(v2_), a3(a3_), v3(v3_) {}
129};
130
131
132
133
134// ////////////////////////
135// v1 + v2
136
138template<typename L, typename R>
143template<typename L, typename R>
148
150// (v1+v2)+v3
152template<typename L, typename R>
157template<typename L, typename R>
162
163template<typename L, typename R>
168template<typename L, typename R>
173
175// alpha*(v1+v2)
176
178template<typename T>
180{
181 return TE_VecAdd2<T> (t.a1*alpha, t.v1, t.a2*alpha, t.v2);
182}
183
185template<typename T>
187{
188 return TE_VecAdd2<T> (t.a1*alpha, t.v1, t.a2*alpha, t.v2);
189}
190
191
193template<typename T>
195{
196 return TE_VecAdd2<T> (t.a1*alpha, t.v1, t.a2*alpha, t.v2, t.a3*alpha, t.v3);
197}
198
200template<typename T>
202{
203 return TE_VecAdd3<T> (t.a1*alpha, t.v1, t.a2*alpha, t.v2, t.a3*alpha, t.v3);
204}
205
206}
207
208
209#endif
Definition te.h:49
double scaling() const
Definition te.h:52
const T & cast() const
Definition te.h:51
Definition te.h:106
const T & v1
Definition te.h:109
double a1
Definition te.h:108
TE_VecAdd2(double a1_, const T &v1_, double a2_, const T &v2_)
Definition te.h:112
double a2
Definition te.h:110
const T & v2
Definition te.h:111
Definition te.h:119
const T & v3
Definition te.h:126
double a2
Definition te.h:123
TE_VecAdd3(double a1_, const T &v1_, double a2_, const T &v2_, double a3_, const T &v3_)
Definition te.h:127
double a3
Definition te.h:125
const T & v1
Definition te.h:122
const T & v2
Definition te.h:124
double a1
Definition te.h:121
Definition te.h:57
TE_VecScale(double a_, const T &v_)
Definition te.h:66
double a
Definition te.h:60
T vector_type
Definition te.h:59
const T & v
Definition te.h:61
const T & vec() const
Definition te.h:64
double scaling() const
Definition te.h:63
Definition te.h:73
double scaling() const
Definition te.h:76
const T & vec() const
Definition te.h:77
T vector_type
Definition te.h:75
the ug namespace
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
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