v0.14.0
Loading...
Searching...
No Matches
Ddg_Expr_equals.hpp
Go to the documentation of this file.
1/* Various assignment operators. I have to explicitly declare the
2 second operator= because otherwise the compiler will generate its
3 own and not use the template code. */
4
5#pragma once
6
7namespace FTensor
8{
9 template <class A, class B, class U, int Current_Dim0, int Current_Dim1,
10 int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
11 char j, char k, char l>
12 void
19 {
20 iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
21 Current_Dim3 - 1)
22 = result(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
23 Current_Dim3 - 1);
27 }
28
29 template <class A, class B, class U, int Current_Dim1, int Current_Dim2,
30 int Current_Dim3, int Dim01, int Dim23, char i, char j, char k,
31 char l>
32 void
35 const Number<1> &, const Number<Current_Dim1> &,
38 {
39 iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1)
40 = result(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1);
44 }
45
46 template <class A, class B, class U, int Current_Dim2, int Current_Dim3,
47 int Dim01, int Dim23, char i, char j, char k, char l>
48 void
51 const Number<1> &, const Number<1> &,
54 {
55 iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1)
56 = result(0, 0, Current_Dim2 - 1, Current_Dim3 - 1);
59 }
60
61 template <class A, class B, class U, int Current_Dim3, int Dim01, int Dim23,
62 char i, char j, char k, char l>
63 void
66 const Number<1> &, const Number<1> &, const Number<1> &,
68 {
69 iter(0, 0, 0, Current_Dim3 - 1) = result(0, 0, 0, Current_Dim3 - 1);
72 }
73
74 template <class A, class B, class U, int Dim01, int Dim23, char i, char j,
75 char k, char l>
76 void
79 const Number<1> &, const Number<1> &, const Number<1> &,
80 const Number<1> &)
81 {
82 iter(0, 0, 0, 0) = result(0, 0, 0, 0);
83 }
84
85 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
86 int Dim23, char i, char j, char k, char l>
87 template <class B, class U>
88 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
90 operator=(const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result)
91 {
94 return *this;
95 }
96
97 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
98 int Dim23, char i, char j, char k, char l>
101 operator=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
102 i, j, k, l> &result)
103 {
104 return operator=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
105 }
106
107 template <bool S> struct Sign_of_T4ddg_plus_equals_T4ddg {};
108
109 template <> struct Sign_of_T4ddg_plus_equals_T4ddg<true> {
110 template <typename L, typename R> static inline void op(L &l, R &&r) {
111 l += r;
112 }
113 };
114
115 template <> struct Sign_of_T4ddg_plus_equals_T4ddg<false> {
116 template <typename L, typename R> static inline void op(L &l, R &&r) {
117 l -= r;
118 }
119 };
120
121 template <class A, class B, class U, int Current_Dim0, int Current_Dim1,
122 int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
123 char j, char k, char l, class Op>
125 A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
127 const Number<Current_Dim2> &, const Number<Current_Dim3> &, const Op &) {
128
129 Op::op(iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
130 Current_Dim3 - 1),
131 result(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
132 Current_Dim3 - 1));
136 }
137
138 template <class A, class B, class U, int Current_Dim1,
139 int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
140 char j, char k, char l, class Op>
142 A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
143 const Number<1> &, const Number<Current_Dim1> &,
144 const Number<Current_Dim2> &, const Number<Current_Dim3> &, const Op &) {
145 Op::op(iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1),
146 result(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1));
150 }
151
152 template <class A, class B, class U, int Current_Dim2,
153 int Current_Dim3, int Dim01, int Dim23, char i, char j, char k,
154 char l, class Op>
156 A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
157 const Number<1> &, const Number<1> &, const Number<Current_Dim2> &,
158 const Number<Current_Dim3> &, const Op &) {
159 Op::op(iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1),
160 result(0, 0, Current_Dim2 - 1, Current_Dim3 - 1));
163 Op());
164 }
165
166 template <class A, class B, class U, int Current_Dim3, int Dim01,
167 int Dim23, char i, char j, char k, char l, class Op>
169 A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
170 const Number<1> &, const Number<1> &, const Number<1> &,
171 const Number<Current_Dim3> &, const Op &) {
172 Op::op(iter(0, 0, 0, Current_Dim3 - 1), result(0, 0, 0, Current_Dim3 - 1));
176 }
177
178 template <class A, class B, class U, int Dim01, int Dim23, char i, char j,
179 char k, char l, class Op>
180 void
183 const Number<1> &, const Number<1> &, const Number<1> &,
184 const Number<1> &, const Op &)
185 {
186 Op::op(iter(0, 0, 0, 0), result(0, 0, 0, 0));
187 }
188
189 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
190 int Dim23, char i, char j, char k, char l>
191 template <class B, class U>
192 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
194 operator+=(const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result)
195 {
199 return *this;
200 }
201
202 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
203 int Dim23, char i, char j, char k, char l>
204 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
206 operator+=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
207 i, j, k, l> &result)
208 {
209 return operator+=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
210 }
211
212 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
213 int Dim23, char i, char j, char k, char l>
214 template <class B, class U>
215 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
217 operator-=(const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result)
218 {
222 return *this;
223 }
224
225 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
226 int Dim23, char i, char j, char k, char l>
227 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
229 operator-=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
230 i, j, k, l> &result)
231 {
232 return operator-=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
233 }
234
235 /* Ddgs*=U */
236
237 template <class A, class T, class U, int Dim01, int Dim23>
239
241 const U &u;
242
243 template <int Current_Dim0, int Current_Dim1, int Current_Dim2,
244 int Current_Dim3>
247 iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
248 Current_Dim3 - 1) *= u;
251 }
252
253 template <int Current_Dim1, int Current_Dim2, int Current_Dim3>
254 void eval(const Number<1> &, const Number<Current_Dim1> &,
256 iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1) *= u;
259 }
260
261 template <int Current_Dim2, int Current_Dim3>
262 void eval(const Number<1> &, const Number<1> &,
264 iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1) *= u;
267 }
268
269 template <int Current_Dim3>
270 void eval(const Number<1> &, const Number<1> &, const Number<1> &,
271 const Number<Current_Dim3> &) {
272 iter(0, 0, 0, Current_Dim3 - 1) *= u;
275 }
276
277 void eval(const Number<1> &, const Number<1> &, const Number<1> &,
278 const Number<1> &) {
279 iter(0, 0, 0, 0) *= u;
280 }
281
282 public:
285
289 };
290
291 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
292 int Dim23, char i, char j, char k, char l>
293 template <class U>
294 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
296 operator*=(const U &d) {
298 return *this;
299 }
300
301 template <class A, class T, class U, int Dim01, int Dim23>
303
305 const U &u;
306
307 template <int Current_Dim0, int Current_Dim1, int Current_Dim2,
308 int Current_Dim3>
316
317 template <int Current_Dim1, int Current_Dim2, int Current_Dim3>
325
326 template <int Current_Dim2, int Current_Dim3>
334
335 template <int Current_Dim3>
343
344 void eval(const Number<1> &, const Number<1> &, const Number<1> &,
345 const Number<1> &) {
347 }
348
349 public:
351
355 };
356
357 template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
358 int Dim23, char i, char j, char k, char l>
359 template <class U>
360 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
361 Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k,
362 l>::operator=(const U &d) {
364 return *this;
365 }
366}
static Index< 'L', 3 > L
constexpr double a
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim3 > &)
void eval(const Number< 1 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
void eval(const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
T4Ddg_equals_generic(Ddg< A, Dim01, Dim23 > &a, const U &b)
void eval(const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Ddg< A, Dim01, Dim23 > & iter
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< 1 > &)
void eval(const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
void eval(const Number< 1 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< 1 > &)
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim3 > &)
void eval(const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
T4Ddg_times_equals_generic(Ddg< A, Dim01, Dim23 > &a, const U &b)
@ R
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition dTensor0.hpp:27
void T4ddg_plus_equals_T4ddg(A &iter, const Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &, const Op &)
void T4ddg_equals_T4ddg(A &iter, const Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
constexpr AssemblyType A