v0.14.0
Tensor4_times_Tensor3_triple.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 namespace FTensor
4 {
5  // A(i,j,k,l) * B(m,n,o) triple contraction
6  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
7  int Dim3, int Dim4, int Dim5, int Dim6, char i, char j, char k,
8  char l, char m, char n, char o, int DimA, int DimX, int DimY,
9  int DimZ, char a, char x, char y, char z>
11  {
14 
15  public:
16  typename promote<T, U>::V operator()(const int N1) const
17  {
18  typename promote<T, U>::V result(0);
19  for(int xx = 0; xx < DimX; ++xx)
20  for(int yy = 0; yy < DimY; ++yy)
21  for(int zz = 0; zz < DimZ; ++zz)
22  {
23  // Permutation is where the indices get checked.
24  result
26  iterA, N1, xx, yy, zz)
28  yy, zz);
29  }
30  return result;
31  }
32 
36  : iterA(iter_a), iterB(iter_b)
37  {}
38  };
39 
40  // A(i,j,k,l)*B(j,k,l)
41  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
42  int Dim3, char i, char j, char k, char l>
43  auto
46  {
47  using TensorExpr
48  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
49  Dim2, Dim3, i, j, k, l, j, k, l, Dim0,
50  Dim1, Dim2, Dim3, i, j, k, l>;
52  TensorExpr(a, b));
53  }
54 
55  // B(j,k,l)*A(i,j,k,l)
56  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
57  int Dim3, char i, char j, char k, char l>
58  auto
61  {
62  return a * b;
63  }
64 
65  // A(i,j,k,l)*B(j,l,k)
66  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
67  int Dim3, char i, char j, char k, char l>
68  auto
71  {
72  using TensorExpr
73  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
74  Dim3, Dim2, i, j, k, l, j, l, k, Dim0,
75  Dim1, Dim2, Dim3, i, j, k, l>;
77  TensorExpr(a, b));
78  }
79 
80  // B(j,l,k)*A(i,j,k,l)
81  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
82  int Dim3, char i, char j, char k, char l>
83  auto
86  {
87  return a * b;
88  }
89 
90  // A(i,j,k,l)*B(k,j,l)
91  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
92  int Dim3, char i, char j, char k, char l>
93  auto
96  {
97  using TensorExpr
98  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
99  Dim1, Dim3, i, j, k, l, k, j, l, Dim0,
100  Dim1, Dim2, Dim3, i, j, k, l>;
102  TensorExpr(a, b));
103  }
104 
105  // B(k,j,l)*A(i,j,k,l)
106  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
107  int Dim3, char i, char j, char k, char l>
108  auto
111  {
112  return a * b;
113  }
114 
115  // A(i,j,k,l)*B(k,l,j)
116  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
117  int Dim3, char i, char j, char k, char l>
118  auto
121  {
122  using TensorExpr
123  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
124  Dim3, Dim1, i, j, k, l, k, l, j, Dim0,
125  Dim1, Dim2, Dim3, i, j, k, l>;
127  TensorExpr(a, b));
128  }
129 
130  // B(k,l,j)*A(i,j,k,l)
131  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
132  int Dim3, char i, char j, char k, char l>
133  auto
136  {
137  return a * b;
138  }
139 
140  // A(i,j,k,l)*B(l,j,k)
141  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
142  int Dim3, char i, char j, char k, char l>
143  auto
146  {
147  using TensorExpr
148  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
149  Dim1, Dim2, i, j, k, l, l, j, k, Dim0,
150  Dim1, Dim2, Dim3, i, j, k, l>;
152  TensorExpr(a, b));
153  }
154 
155  // B(l,j,k)*A(i,j,k,l)
156  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
157  int Dim3, char i, char j, char k, char l>
158  auto
161  {
162  return a * b;
163  }
164 
165  // A(i,j,k,l)*B(l,k,j)
166  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
167  int Dim3, char i, char j, char k, char l>
168  auto
171  {
172  using TensorExpr
173  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
174  Dim2, Dim1, i, j, k, l, l, k, j, Dim0,
175  Dim1, Dim2, Dim3, i, j, k, l>;
177  TensorExpr(a, b));
178  }
179 
180  // B(l,k,j)*A(i,j,k,l)
181  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
182  int Dim3, char i, char j, char k, char l>
183  auto
186  {
187  return a * b;
188  }
189 
190  // A(i,j,k,l)*B(i,k,l)
191  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
192  int Dim3, char i, char j, char k, char l>
193  auto
196  {
197  using TensorExpr
198  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
199  Dim2, Dim3, i, j, k, l, i, k, l, Dim1,
200  Dim0, Dim2, Dim3, j, i, k, l>;
202  TensorExpr(a, b));
203  }
204 
205  // B(i,k,l)*A(i,j,k,l)
206  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
207  int Dim3, char i, char j, char k, char l>
208  auto
211  {
212  return a * b;
213  }
214 
215  // A(i,j,k,l)*B(i,l,k)
216  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
217  int Dim3, char i, char j, char k, char l>
218  auto
221  {
222  using TensorExpr
223  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
224  Dim3, Dim2, i, j, k, l, i, l, k, Dim1,
225  Dim0, Dim2, Dim3, j, i, k, l>;
227  TensorExpr(a, b));
228  }
229 
230  // B(i,l,k)*A(i,j,k,l)
231  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
232  int Dim3, char i, char j, char k, char l>
233  auto
236  {
237  return a * b;
238  }
239 
240  // A(i,j,k,l)*B(k,i,l)
241  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
242  int Dim3, char i, char j, char k, char l>
243  auto
246  {
247  using TensorExpr
248  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
249  Dim0, Dim3, i, j, k, l, k, i, l, Dim1,
250  Dim0, Dim2, Dim3, j, i, k, l>;
252  TensorExpr(a, b));
253  }
254 
255  // B(k,i,l)*A(i,j,k,l)
256  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
257  int Dim3, char i, char j, char k, char l>
258  auto
261  {
262  return a * b;
263  }
264 
265  // A(i,j,k,l)*B(k,l,i)
266  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
267  int Dim3, char i, char j, char k, char l>
268  auto
271  {
272  using TensorExpr
273  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
274  Dim3, Dim0, i, j, k, l, k, l, i, Dim1,
275  Dim0, Dim2, Dim3, j, i, k, l>;
277  TensorExpr(a, b));
278  }
279 
280  // B(k,l,i)*A(i,j,k,l)
281  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
282  int Dim3, char i, char j, char k, char l>
283  auto
286  {
287  return a * b;
288  }
289 
290  // A(i,j,k,l)*B(l,i,k)
291  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
292  int Dim3, char i, char j, char k, char l>
293  auto
296  {
297  using TensorExpr
298  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
299  Dim0, Dim2, i, j, k, l, l, i, k, Dim1,
300  Dim0, Dim2, Dim3, j, i, k, l>;
302  TensorExpr(a, b));
303  }
304 
305  // B(l,i,k)*A(i,j,k,l)
306  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
307  int Dim3, char i, char j, char k, char l>
308  auto
311  {
312  return a * b;
313  }
314 
315  // A(i,j,k,l)*B(l,k,i)
316  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
317  int Dim3, char i, char j, char k, char l>
318  auto
321  {
322  using TensorExpr
323  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
324  Dim2, Dim0, i, j, k, l, l, k, i, Dim1,
325  Dim0, Dim2, Dim3, j, i, k, l>;
327  TensorExpr(a, b));
328  }
329 
330  // B(l,k,i)*A(i,j,k,l)
331  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
332  int Dim3, char i, char j, char k, char l>
333  auto
336  {
337  return a * b;
338  }
339 
340  // A(i,j,k,l)*B(i,j,l)
341  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
342  int Dim3, char i, char j, char k, char l>
343  auto
346  {
347  using TensorExpr
348  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
349  Dim1, Dim3, i, j, k, l, i, j, l, Dim2,
350  Dim0, Dim1, Dim3, k, i, j, l>;
352  TensorExpr(a, b));
353  }
354 
355  // B(i,j,l)*A(i,j,k,l)
356  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
357  int Dim3, char i, char j, char k, char l>
358  auto
361  {
362  return a * b;
363  }
364 
365  // A(i,j,k,l)*B(i,l,j)
366  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
367  int Dim3, char i, char j, char k, char l>
368  auto
371  {
372  using TensorExpr
373  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
374  Dim3, Dim1, i, j, k, l, i, l, j, Dim2,
375  Dim0, Dim1, Dim3, k, i, j, l>;
377  TensorExpr(a, b));
378  }
379 
380  // B(i,l,j)*A(i,j,k,l)
381  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
382  int Dim3, char i, char j, char k, char l>
383  auto
386  {
387  return a * b;
388  }
389 
390  // A(i,j,k,l)*B(j,i,l)
391  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
392  int Dim3, char i, char j, char k, char l>
393  auto
396  {
397  using TensorExpr
398  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
399  Dim0, Dim3, i, j, k, l, j, i, l, Dim2,
400  Dim0, Dim1, Dim3, k, i, j, l>;
402  TensorExpr(a, b));
403  }
404 
405  // B(j,i,l)*A(i,j,k,l)
406  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
407  int Dim3, char i, char j, char k, char l>
408  auto
411  {
412  return a * b;
413  }
414 
415  // A(i,j,k,l)*B(j,l,i)
416  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
417  int Dim3, char i, char j, char k, char l>
418  auto
421  {
422  using TensorExpr
423  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
424  Dim3, Dim0, i, j, k, l, j, l, i, Dim2,
425  Dim0, Dim1, Dim3, k, i, j, l>;
427  TensorExpr(a, b));
428  }
429 
430  // B(j,l,i)*A(i,j,k,l)
431  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
432  int Dim3, char i, char j, char k, char l>
433  auto
436  {
437  return a * b;
438  }
439 
440  // A(i,j,k,l)*B(l,i,j)
441  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
442  int Dim3, char i, char j, char k, char l>
443  auto
446  {
447  using TensorExpr
448  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
449  Dim0, Dim1, i, j, k, l, l, i, j, Dim2,
450  Dim0, Dim1, Dim3, k, i, j, l>;
452  TensorExpr(a, b));
453  }
454 
455  // B(l,i,j)*A(i,j,k,l)
456  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
457  int Dim3, char i, char j, char k, char l>
458  auto
461  {
462  return a * b;
463  }
464 
465  // A(i,j,k,l)*B(l,j,i)
466  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
467  int Dim3, char i, char j, char k, char l>
468  auto
471  {
472  using TensorExpr
473  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
474  Dim1, Dim0, i, j, k, l, l, j, i, Dim2,
475  Dim0, Dim1, Dim3, k, i, j, l>;
477  TensorExpr(a, b));
478  }
479 
480  // B(l,j,i)*A(i,j,k,l)
481  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
482  int Dim3, char i, char j, char k, char l>
483  auto
486  {
487  return a * b;
488  }
489 
490  // A(i,j,k,l)*B(i,j,k)
491  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
492  int Dim3, char i, char j, char k, char l>
493  auto
496  {
497  using TensorExpr
498  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
499  Dim1, Dim2, i, j, k, l, i, j, k, Dim3,
500  Dim0, Dim1, Dim2, l, i, j, k>;
502  TensorExpr(a, b));
503  }
504 
505  // B(i,j,k)*A(i,j,k,l)
506  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
507  int Dim3, char i, char j, char k, char l>
508  auto
511  {
512  return a * b;
513  }
514 
515  // A(i,j,k,l)*B(i,k,j)
516  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
517  int Dim3, char i, char j, char k, char l>
518  auto
521  {
522  using TensorExpr
523  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
524  Dim2, Dim1, i, j, k, l, i, k, j, Dim3,
525  Dim0, Dim1, Dim2, l, i, j, k>;
527  TensorExpr(a, b));
528  }
529 
530  // B(i,k,j)*A(i,j,k,l)
531  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
532  int Dim3, char i, char j, char k, char l>
533  auto
536  {
537  return a * b;
538  }
539 
540  // A(i,j,k,l)*B(j,i,k)
541  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
542  int Dim3, char i, char j, char k, char l>
543  auto
546  {
547  using TensorExpr
548  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
549  Dim0, Dim2, i, j, k, l, j, i, k, Dim3,
550  Dim0, Dim1, Dim2, l, i, j, k>;
552  TensorExpr(a, b));
553  }
554 
555  // B(j,i,k)*A(i,j,k,l)
556  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
557  int Dim3, char i, char j, char k, char l>
558  auto
561  {
562  return a * b;
563  }
564 
565  // A(i,j,k,l)*B(j,k,i)
566  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
567  int Dim3, char i, char j, char k, char l>
568  auto
571  {
572  using TensorExpr
573  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
574  Dim2, Dim0, i, j, k, l, j, k, i, Dim3,
575  Dim0, Dim1, Dim2, l, i, j, k>;
577  TensorExpr(a, b));
578  }
579 
580  // B(j,k,i)*A(i,j,k,l)
581  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
582  int Dim3, char i, char j, char k, char l>
583  auto
586  {
587  return a * b;
588  }
589 
590  // A(i,j,k,l)*B(k,i,j)
591  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
592  int Dim3, char i, char j, char k, char l>
593  auto
596  {
597  using TensorExpr
598  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
599  Dim0, Dim1, i, j, k, l, k, i, j, Dim3,
600  Dim0, Dim1, Dim2, l, i, j, k>;
602  TensorExpr(a, b));
603  }
604 
605  // B(k,i,j)*A(i,j,k,l)
606  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
607  int Dim3, char i, char j, char k, char l>
608  auto
611  {
612  return a * b;
613  }
614 
615  // A(i,j,k,l)*B(k,j,i)
616  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
617  int Dim3, char i, char j, char k, char l>
618  auto
621  {
622  using TensorExpr
623  = Tensor4_times_Tensor3_triple<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
624  Dim1, Dim0, i, j, k, l, k, j, i, Dim3,
625  Dim0, Dim1, Dim2, l, i, j, k>;
627  TensorExpr(a, b));
628  }
629 
630  // B(k,j,i)*A(i,j,k,l)
631  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
632  int Dim3, char i, char j, char k, char l>
633  auto
636  {
637  return a * b;
638  }
639 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::operator*
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)
Definition: Ddg_times_Ddg.hpp:79
FTensor::Permutation3
Definition: Permutation3.hpp:8
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Permutation4::eval
U eval(const Tensor4_Expr< B, U, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &rhs, const int N0, const int N1, const int N2, const int N3)
Definition: Permutation4.hpp:15
FTensor::Tensor4_times_Tensor3_triple::Tensor4_times_Tensor3_triple
Tensor4_times_Tensor3_triple(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &iter_a, const Tensor3_Expr< B, U, Dim4, Dim5, Dim6, m, n, o > &iter_b)
Definition: Tensor4_times_Tensor3_triple.hpp:33
FTensor::Permutation3::eval
U eval(const Tensor3_Expr< B, U, Dim0, Dim1, Dim2, i, j, k > &rhs, const int N0, const int N1, const int N2)
Definition: Permutation3.hpp:13
FTensor::Tensor4_times_Tensor3_triple::iterB
Tensor3_Expr< B, U, Dim4, Dim5, Dim6, m, n, o > iterB
Definition: Tensor4_times_Tensor3_triple.hpp:13
FTensor::Tensor4_times_Tensor3_triple::iterA
Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor3_triple.hpp:12
FTensor::Tensor4_Expr
Definition: Tensor4_Expr.hpp:25
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_times_Tensor3_triple::operator()
promote< T, U >::V operator()(const int N1) const
Definition: Tensor4_times_Tensor3_triple.hpp:16
FTensor::Tensor3_Expr< B, U, Dim4, Dim5, Dim6, m, n, o >
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
convert.n
n
Definition: convert.py:82
FTensor::Tensor4_times_Tensor3_triple
Definition: Tensor4_times_Tensor3_triple.hpp:10
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Permutation4
Definition: Permutation4.hpp:9
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21