LoAdSG
system.h
1// ------------------------------------------------------------
2//
3// shift.h
4//
5// ------------------------------------------------------------
6#ifndef SYSTEM_H
7#define SYSTEM_H
8
9
10#include "../myAssert.h"
11#include "extempAlg.h"
12#include "../sgrid/sparseGrid.h"
13#include "../indices/index.h"
14#include "vector.h"
15
16
17
18
19
21// 1. class ShiftExpr
22// 2. system of equation operators
24
25
26template<class B>
27class DWrapSim {
28 private:
29 // variable
30 double* dataTableVector;
31
32 // expression
33 B bo;
34 public:
35 DWrapSim(const VectorSparseG& a, const ExprSparseG<B>& b) : dataTableVector(a.dataTableVector), bo(b) { }
36 void RunValue(int i, const IndexDimension& I) const {
37 dataTableVector[i]=bo.getValue(i, I);
38 // geht noch icht!!
39 };
40
41
42 ExpressionDescription getDescription() const {
43 return ExpressionDescription(bo.getDescription());
44 }
45
46};
47
48
49/* DExprAnd */
50template<class A, class B>
51class ExprAndSparseG : public ExprSparseG<ExprAndSparseG<A, B> > {
52 const A a_;
53 DWrapSim<B> b_;
54 public:
55 ExprAndSparseG(const A& a, DWrapSim<B>& b) : a_(a), b_(b) {}
56
57 double getValue(int i, const IndexDimension& I) const {
58 b_.RunValue(i,I);
59 return a_.getValue(i,I);
60 }
61
62 ExpressionDescription getDescription() const {
63 return ExpressionDescription(a_.getDescription(),b_.getDescription());
64 }
65 AdaptiveSparseGrid* getSparseGrid() const { return a_.getSparseGrid(); }
66
67 // at the and of an iteration of an expression
68 //void clean() const { a_.clean(); b_.clean(); };
69};
70
71/*
72// DExprAndSim
73template<class A, class B>
74class DExprAndSim : public DWrapSim<DExprAndSim<A, B> > {
75 A a_;
76 B b_;
77 public:
78 DExprAndSim(const A& a, const B& b) : a_(a), b_(b) {}
79
80 void RunValue(double* data, const IndexDimension& I) const {
81 b_.RunValue(data,I);
82 a_.RunValue(data,I);
83 }
84 void RunDataTableVector(int i) const {
85 b_.RunDataTableVector(i);
86 a_.RunDataTableVector(i);
87 }
88 ExpressionDescription getDescription() const {
89 return ExpressionDescription(a_.getDescription(),b_.getDescription());
90 }
91 AdaptiveSparseGrid* getSparseGrid() const { return a_.getSparseGrid(); }
92
93 // at the and of an iteration of an expression
94 //void clean() const { a_.clean(); b_.clean(); };
95};
96*/
97
98class DExprLIT : public ExprSparseG<DExprLIT> {
99 public:
100 DExprLIT(const double a_): a(a_) {}
101
102 double getValue(int i, const IndexDimension& I) const { return a; }
103
104 ExpressionDescription getDescription() const { return ExpressionDescription(false); }
105 AdaptiveSparseGrid* getSparseGrid() const { return NULL; } // Das ist natürlich komisch so! Riccarda: Ist das ein Problem???
106 private:
107 double a;
108};
109
110
112// system of equation operators
114
115
116/* @{ */
117
118template<class A, class B>
119ExprAndSparseG< A, B >
120operator&(const ExprSparseG<A>& a, DWrapSim<B> b) {
121 return ExprAndSparseG< A, B > (a,b);
122}
123
124
125/*
126template<class A, class B>
127ExprAndSparseG< A, B >
128operator&(A a, DWrapSim<B> b) {
129 return ExprAndSparseG< A, B > (a,b);
130}
131*/
132
133/*
134template<class A, class B>
135DExprAndSim< A, B >
136operator&(const DWrapSim<A>& a, const DWrapSim<B>& b) {
137 return DExprAndSim< A, B > (a,b);
138}
139*/
140
141/*
142template<class B>
143ExprAndSparseG< VectorSparseG, B >
144operator&(VectorSparseG& a, const DWrapSim<B>& b) {
145 return ExprAndSparseG< VectorSparseG, B > (a,b);
146}
147*/
148
149template<class B>
150ExprAndSparseG< DExprLIT, B >
151operator&(double a, const DWrapSim<B>& b) {
152 return ExprAndSparseG< DExprLIT, B > (DExprLIT(a),b);
153}
154
155
156/*
157template<class B>
158DExpr<DExprAnd<Local_var, DWrapSim<B> > >
159operator&(Local_var &a, const DWrapSim<B>& b)
160{
161 typedef DExprAnd<Local_var, DWrapSim<B> > ExprT;
162 return DExpr<ExprT>(ExprT(a,b));
163}
164*/
165
166template<class B>
167DWrapSim<B>
168operator== (VectorSparseG& a, const ExprSparseG<B>& b_) {
169 return DWrapSim<B>(a,b_);
170}
171
172
173/*
174DWrapSim<DExprSimLit>
175operator== (Variable& a, double value);
176
177
178template<class B>
179DWrapSim<DExprSimloc<B> >
180operator== (const Local_var& a, const B& b_)
181{
182 typedef DWrapSim<DExprSimloc<B> > ExprT;
183 return ExprT(DExprSimloc<B>(a,b_));
184}
185
186DWrapSim<DExprSimlocLit>
187operator== (const Local_var& a, double x);
188
189DWrapSim<DExprSimloc<DExprVAR> >
190operator== (const Local_var& a, Variable& b);
191*/
192
193
195
196
197#endif
Definition sparseGrid.h:277