v0.13.2
Loading...
Searching...
No Matches
Tensor3_times_Dg.hpp
Go to the documentation of this file.
1/* Contracts a Tensor3 with a Dg, yielding a typename promote<T,U>::V,
2 Tensor2, or Tensor4. */
3
4#pragma once
5
6namespace FTensor
7{
8 /* A(i,j,k)*B(i,j,k) */
9
10 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
11 char j, char k, int Current_Dim0, int Current_Dim1,
12 int Current_Dim2>
13 typename promote<T, U>::V
18 {
19 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
20 * b(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
24 }
25
26 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
27 char j, char k, int Current_Dim0, int Current_Dim2>
28 typename promote<T, U>::V
31 const Number<Current_Dim0> &, const Number<1> &,
33 {
34 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
35 * b(Current_Dim0 - 1, 0, Current_Dim2 - 1)
38 }
39
40 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
41 char j, char k, int Current_Dim0>
42 typename promote<T, U>::V
45 const Number<Current_Dim0> &, const Number<1> &,
46 const Number<1> &)
47 {
48 return a(Current_Dim0 - 1, 0, 0) * b(Current_Dim0 - 1, 0, 0)
50 Number<Dim2>());
51 }
52
53 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
54 char j, char k>
55 typename promote<T, U>::V
58 const Number<1> &, const Number<1> &, const Number<1> &)
59 {
60 return a(0, 0, 0) * b(0, 0, 0);
61 }
62
63 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
64 char j, char k>
65 typename promote<T, U>::V
68 {
70 Number<Dim2>());
71 }
72
73 /* A(i,j,k)*B(k,i,j) */
74
75 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
76 char j, char k, int Current_Dim0, int Current_Dim1,
77 int Current_Dim2>
78 typename promote<T, U>::V
83 {
84 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
85 * b(Current_Dim2 - 1, Current_Dim0 - 1, Current_Dim1 - 1)
89 }
90
91 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
92 char j, char k, int Current_Dim0, int Current_Dim2>
93 typename promote<T, U>::V
96 const Number<Current_Dim0> &, const Number<1> &,
98 {
99 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
100 * b(Current_Dim2 - 1, Current_Dim0 - 1, 0)
103 }
104
105 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
106 char j, char k, int Current_Dim0>
107 typename promote<T, U>::V
110 const Number<Current_Dim0> &, const Number<1> &,
111 const Number<1> &)
112 {
113 return a(Current_Dim0 - 1, 0, 0) * b(0, Current_Dim0 - 1, 0)
116 }
117
118 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
119 char j, char k>
120 typename promote<T, U>::V
123 const Number<1> &, const Number<1> &, const Number<1> &)
124 {
125 return a(0, 0, 0) * b(0, 0, 0);
126 }
127
128 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
129 char j, char k>
130 typename promote<T, U>::V
133 {
135 Number<Dim>());
136 }
137
138 /* A(i,j,k)*B(j,k,i) */
139
140 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
141 char j, char k, int Current_Dim0, int Current_Dim1,
142 int Current_Dim2>
143 typename promote<T, U>::V
147 const Number<Current_Dim2> &)
148 {
149 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
150 * b(Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim0 - 1)
154 }
155
156 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
157 char j, char k, int Current_Dim0, int Current_Dim2>
158 typename promote<T, U>::V
161 const Number<Current_Dim0> &, const Number<1> &,
162 const Number<Current_Dim2> &)
163 {
164 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
165 * b(0, Current_Dim2 - 1, Current_Dim0 - 1)
168 }
169
170 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
171 char j, char k, int Current_Dim0>
172 typename promote<T, U>::V
175 const Number<Current_Dim0> &, const Number<1> &,
176 const Number<1> &)
177 {
178 return a(Current_Dim0 - 1, 0, 0) * b(0, 0, Current_Dim0 - 1)
180 Number<Dim>());
181 }
182
183 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
184 char j, char k>
185 typename promote<T, U>::V
188 const Number<1> &, const Number<1> &, const Number<1> &)
189 {
190 return a(0, 0, 0) * b(0, 0, 0);
191 }
192
193 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
194 char j, char k>
195 typename promote<T, U>::V
198 {
200 Number<Dim>());
201 }
202
203 /* A(i,j,k)*B(j,i,k) */
204
205 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
206 char j, char k, int Current_Dim0, int Current_Dim1,
207 int Current_Dim2>
208 typename promote<T, U>::V
212 const Number<Current_Dim2> &)
213 {
214 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
215 * b(Current_Dim1 - 1, Current_Dim0 - 1, Current_Dim2 - 1)
219 }
220
221 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
222 char j, char k, int Current_Dim0, int Current_Dim2>
223 typename promote<T, U>::V
226 const Number<Current_Dim0> &, const Number<1> &,
227 const Number<Current_Dim2> &)
228 {
229 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
230 * b(0, Current_Dim0 - 1, Current_Dim2 - 1)
233 }
234
235 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
236 char j, char k, int Current_Dim0>
237 typename promote<T, U>::V
240 const Number<Current_Dim0> &, const Number<1> &,
241 const Number<1> &)
242 {
243 return a(Current_Dim0 - 1, 0, 0) * b(0, Current_Dim0 - 1, 0)
245 Number<Dim2>());
246 }
247
248 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
249 char j, char k>
250 typename promote<T, U>::V
253 const Number<1> &, const Number<1> &, const Number<1> &)
254 {
255 return a(0, 0, 0) * b(0, 0, 0);
256 }
257
258 template <class A, class B, class T, class U, int Dim, int Dim2, char i,
259 char j, char k>
260 typename promote<T, U>::V
263 {
265 Number<Dim2>());
266 }
267
268 /* A(i,j,k)*B(k,j,i) */
269
270 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
271 char j, char k, int Current_Dim0, int Current_Dim1,
272 int Current_Dim2>
273 typename promote<T, U>::V
277 const Number<Current_Dim2> &)
278 {
279 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
280 * b(Current_Dim2 - 1, Current_Dim1 - 1, Current_Dim0 - 1)
284 }
285
286 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
287 char j, char k, int Current_Dim0, int Current_Dim2>
288 typename promote<T, U>::V
291 const Number<Current_Dim0> &, const Number<1> &,
292 const Number<Current_Dim2> &)
293 {
294 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
295 * b(Current_Dim2 - 1, 0, Current_Dim0 - 1)
298 }
299
300 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
301 char j, char k, int Current_Dim0>
302 typename promote<T, U>::V
305 const Number<Current_Dim0> &, const Number<1> &,
306 const Number<1> &)
307 {
308 return a(Current_Dim0 - 1, 0, 0) * b(0, 0, Current_Dim0 - 1)
310 Number<Dim>());
311 }
312
313 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
314 char j, char k>
315 typename promote<T, U>::V
318 const Number<1> &, const Number<1> &, const Number<1> &)
319 {
320 return a(0, 0, 0) * b(0, 0, 0);
321 }
322
323 template <class A, class B, class T, class U, int Dim0, int Dim, char i,
324 char j, char k>
325 typename promote<T, U>::V
328 {
330 Number<Dim>());
331 }
332
333 /* A(i,j,k)*B(i,k,j) */
334
335 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
336 char j, char k, int Current_Dim0, int Current_Dim1,
337 int Current_Dim2>
338 typename promote<T, U>::V
342 const Number<Current_Dim2> &)
343 {
344 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1)
345 * b(Current_Dim0 - 1, Current_Dim2 - 1, Current_Dim1 - 1)
349 }
350
351 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
352 char j, char k, int Current_Dim0, int Current_Dim2>
353 typename promote<T, U>::V
356 const Number<Current_Dim0> &, const Number<1> &,
357 const Number<Current_Dim2> &)
358 {
359 return a(Current_Dim0 - 1, 0, Current_Dim2 - 1)
360 * b(Current_Dim0 - 1, Current_Dim2 - 1, 0)
363 }
364
365 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
366 char j, char k, int Current_Dim0>
367 typename promote<T, U>::V
370 const Number<Current_Dim0> &, const Number<1> &,
371 const Number<1> &)
372 {
373 return a(Current_Dim0 - 1, 0, 0) * b(Current_Dim0 - 1, 0, 0)
376 }
377
378 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
379 char j, char k>
380 typename promote<T, U>::V
383 const Number<1> &, const Number<1> &, const Number<1> &)
384 {
385 return a(0, 0, 0) * b(0, 0, 0);
386 }
387
388 template <class A, class B, class T, class U, int Dim, int Dim1, char i,
389 char j, char k>
390 typename promote<T, U>::V
393 {
395 Number<Dim>());
396 }
397
398 /* A(j,i,k)*B(k,l,j) */
399
400 template <class A, class B, class T, class U, int Dim2, int Dim1, int Dim01,
401 char i, char j, char k, char l>
403 {
406
407 template <int Current_Dim0, int Current_Dim1>
408 typename promote<T, U>::V
409 eval(const int N1, const int N2, const Number<Current_Dim0> &,
410 const Number<Current_Dim1> &) const
411 {
412 return iterA(Current_Dim0 - 1, N1, Current_Dim1 - 1)
413 * iterB(Current_Dim1 - 1, N2, Current_Dim0 - 1)
416 }
417 template <int Current_Dim1>
418 typename promote<T, U>::V
419 eval(const int N1, const int N2, const Number<1> &,
420 const Number<Current_Dim1> &) const
421 {
422 return iterA(0, N1, Current_Dim1 - 1) * iterB(Current_Dim1 - 1, N2, 0)
424 }
425 typename promote<T, U>::V eval(const int N1, const int N2,
426 const Number<1> &, const Number<1> &) const
427 {
428 return iterA(0, N1, 0) * iterB(0, N2, 0);
429 }
430
431 public:
435 : iterA(a), iterB(b)
436 {}
437 typename promote<T, U>::V operator()(const int N1, const int N2) const
438 {
439 return eval(N1, N2, Number<Dim2>(), Number<Dim01>());
440 }
441 };
442
443 template <class A, class B, class T, class U, int Dim2, int Dim1, int Dim01,
444 char i, char j, char k, char l>
445 Tensor2_Expr<Tensor3_times_Dg_02_20<A, B, T, U, Dim2, Dim1, Dim01, i, j, k, l>,
446 typename promote<T, U>::V, Dim1, Dim01, i, l>
449 {
450 using TensorExpr
453 l>(TensorExpr(a, b));
454 }
455
456 /* B(k,l,j)*A(j,i,k) */
457
458 /* A(i,j,k)*B(l,k,m) -> Tensor4 */
459
460 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
461 int Dim, char i, char j, char k, char l, char m>
463 {
466
467 template <int Current_Dim>
468 typename promote<T, U>::V
469 eval(const int N1, const int N2, const int N3, const int N4,
470 const Number<Current_Dim> &) const
471 {
472 return iterA(N1, N2, Current_Dim - 1) * iterB(N3, Current_Dim - 1, N4)
473 + eval(N1, N2, N3, N4, Number<Current_Dim - 1>());
474 }
475 typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
476 const int N4, const Number<1> &) const
477 {
478 return iterA(N1, N2, 0) * iterB(N3, 0, N4);
479 }
480
481 public:
482 typename promote<T, U>::V
483 operator()(const int N1, const int N2, const int N3, const int N4) const
484 {
485 return eval(N1, N2, N3, N4, Number<Dim>());
486 }
489 : iterA(a), iterB(b)
490 {}
491 };
492
493 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
494 int Dim, char i, char j, char k, char l, char m>
495 Tensor4_Expr<
496 Tensor3_times_Dg<A, B, T, U, Dim0, Dim1, Dim, Dim2, i, j, k, l, m>,
497 typename promote<T, U>::V, Dim0, Dim1, Dim, Dim2, i, j, l, m>
500 {
501 using TensorExpr
504 Dim2, i, j, l, m>(TensorExpr(a, b));
505 }
506
507 /* Yield Tensor 2*/
508
509 /* A(i,j,k) * B(i,j,l) -> Tensor2 */
510
511 template <class A, class B, class T, class U, int Dim03, int Dim14, int Dim2,
512 int Dim5, char i, char j, char k, char l>
516
517 template <int CurrentDim0, int CurrentDim1>
518 typename promote<T, U>::V eval(const int N1, const int N2,
519 const Number<CurrentDim0> &,
520 const Number<CurrentDim1> &) const {
521 return iterA(CurrentDim0 - 1, CurrentDim1 - 1, N1) *
522 iterB(CurrentDim0 - 1, CurrentDim1 - 1, N2) +
524 }
525 template <int CurrentDim0>
526 typename promote<T, U>::V eval(const int N1, const int N2,
527 const Number<CurrentDim0> &,
528 const Number<1> &) const {
529 return iterA(CurrentDim0 - 1, 0, N1) * iterB(CurrentDim0 - 1, 0, N2) +
531 }
532 typename promote<T, U>::V eval(const int N1, const int N2,
533 const Number<1> &, const Number<1> &) const {
534 return iterA(0, 0, N1) * iterB(0, 0, N2);
535 }
536
537 public:
541 : iterA(a), iterB(b) {
542
543 static_assert(Dim03 == Dim14, "Dimension 03 should be as Dim14");
544 }
545 typename promote<T, U>::V operator()(const int &N1, const int &N2) const {
546 return eval(N1, N2, Number<Dim03>(), Number<Dim14>());
547 }
548 };
549
550 template <class A, class B, class T, class U, int Dim03, int Dim14, int Dim2,
551 int Dim5, char i, char j, char k, char l>
552 Tensor2_Expr<
553 Tensor3_times_Dg_12_12<A, B, T, U, Dim03, Dim14, Dim2, Dim5, i, j, k, l>,
554 typename promote<T, U>::V, Dim2, Dim5, k, l>
557 using TensorExpr = Tensor3_times_Dg_12_12<A, B, T, U, Dim03, Dim14, Dim2,
558 Dim5, i, j, k, l>;
560 l>(TensorExpr(a, b));
561 };
562
563 /* B(i,j,l)* A(i,j,k) -> Tensor2 */
564
565 template <class A, class B, class T, class U, int Dim03, int Dim14, int Dim2,
566 int Dim5, char i, char j, char k, char l>
567 Tensor2_Expr<
568 Tensor3_times_Dg_12_12<A, B, T, U, Dim03, Dim14, Dim2, Dim5, i, j, k, l>,
569 typename promote<T, U>::V, Dim2, Dim5, k, l>
572 using TensorExpr = Tensor3_times_Dg_12_12<A, B, T, U, Dim03, Dim14, Dim2,
573 Dim5, i, j, k, l>;
575 l>(TensorExpr(a, b));
576 };
577}
static Number< 2 > N2
static Number< 1 > N1
constexpr double a
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< 1 > &) const
Dg_Expr< B, U, Dim01, Dim2, k, l, j > iterB
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V operator()(const int N1, const int N2) const
Tensor3_Expr< A, T, Dim2, Dim1, Dim01, j, i, k > iterA
Tensor3_times_Dg_02_20(const Tensor3_Expr< A, T, Dim2, Dim1, Dim01, j, i, k > &a, const Dg_Expr< B, U, Dim01, Dim2, k, l, j > &b)
promote< T, U >::V operator()(const int &N1, const int &N2) const
promote< T, U >::V eval(const int N1, const int N2, const Number< CurrentDim0 > &, const Number< CurrentDim1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< CurrentDim0 > &, const Number< 1 > &) const
Tensor3_Expr< A, T, Dim03, Dim14, Dim2, i, j, k > iterA
Tensor3_times_Dg_12_12(const Tensor3_Expr< A, T, Dim03, Dim14, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim03, Dim5, i, j, l > &b)
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< 1 > &) const
Dg_Expr< B, U, Dim03, Dim5, i, j, l > iterB
Tensor3_Expr< A, T, Dim0, Dim1, Dim, i, j, k > iterA
Tensor3_times_Dg(const Tensor3_Expr< A, T, Dim0, Dim1, Dim, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim2, l, k, m > &b)
Dg_Expr< B, U, Dim, Dim2, l, k, m > iterB
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &) const
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
FTensor::Index< 'm', SPACE_DIM > m
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
promote< T, U >::V T3_times_T3dg_012(const Tensor3_Expr< A, T, Dim, Dim, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim2, i, j, k > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
promote< T, U >::V T3_times_T3dg_201(const Tensor3_Expr< A, T, Dim, Dim1, Dim, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim1, k, i, j > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
promote< T, U >::V T3_times_T3dg_210(const Tensor3_Expr< A, T, Dim0, Dim, Dim, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim0, k, j, i > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
promote< T, U >::V T3_times_T3dg_021(const Tensor3_Expr< A, T, Dim, Dim1, Dim, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim1, i, k, j > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
promote< T, U >::V T3_times_T3dg_120(const Tensor3_Expr< A, T, Dim0, Dim, Dim, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim0, j, k, i > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
promote< T, U >::V operator*(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, k, j, l > &b)
promote< T, U >::V T3_times_T3dg_102(const Tensor3_Expr< A, T, Dim, Dim, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim, Dim2, j, i, k > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &)
constexpr AssemblyType A