v0.14.0
Tensor4_times_Tensor2_single.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) single contraction
6  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
7  int Dim3, int Dim4, int Dim5, char i, char j, char k, char l,
8  char m, char n, int DimA, int DimB, int DimC, int DimX, int DimY,
9  char a, char b, char c, char x, char y>
11  {
14 
15  public:
16  typename promote<T, U>::V
17  operator()(const int N1, const int N2, const int N3, const int N4) const
18  {
19  typename promote<T, U>::V result(0);
20  for(int xx = 0; xx < DimX; ++xx)
21  {
22  // Permutation is where the indices get checked.
24  iterA, N1, N2, N3, xx)
26  }
27  return result;
28  }
29 
33  : iterA(iter_a), iterB(iter_b)
34  {}
35  };
36 
37  // A(i,j,k,l)*B(l,m)
38 
39  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
40  int Dim3, int Dim4, char i, char j, char k, char l, char m>
41  auto
44  {
45  using TensorExpr
46  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim3,
47  Dim4, i, j, k, l, l, m, Dim0, Dim1, Dim2,
48  Dim3, Dim4, i, j, k, l, m>;
50  Dim2, Dim4, i, j, k, m>(TensorExpr(a, b));
51  }
52 
53  // B(l,m)*A(i,j,k,l)
54 
55  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
56  int Dim3, int Dim4, char i, char j, char k, char l, char m>
57  auto
60  {
61  return a * b;
62  }
63 
64  // A(i,j,k,l)*B(m,l)
65  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
66  int Dim3, int Dim4, char i, char j, char k, char l, char m>
67  auto
70  {
71  using TensorExpr
72  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4,
73  Dim3, i, j, k, l, m, l, Dim0, Dim1, Dim2,
74  Dim3, Dim4, i, j, k, l, m>;
76  Dim2, Dim4, i, j, k, m>(TensorExpr(a, b));
77  }
78 
79  // B(m,l)*A(i,j,k,l)
80  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
81  int Dim3, int Dim4, char i, char j, char k, char l, char m>
82  auto
85  {
86  return a * b;
87  }
88 
89  // A(i,j,k,l)*B(k,m)
90  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
91  int Dim3, int Dim4, char i, char j, char k, char l, char m>
92  auto
95  {
96  using TensorExpr
97  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim2,
98  Dim4, i, j, k, l, k, m, Dim0, Dim1, Dim3,
99  Dim2, Dim4, i, j, l, k, m>;
101  Dim3, Dim4, i, j, l, m>(TensorExpr(a, b));
102  }
103 
104  // B(k,m)*A(i,j,k,l)
105  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
106  int Dim3, int Dim4, char i, char j, char k, char l, char m>
107  auto
110  {
111  return a * b;
112  }
113 
114  // A(i,j,k,l)*B(m,k)
115  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
116  int Dim3, int Dim4, char i, char j, char k, char l, char m>
117  auto
120  {
121  using TensorExpr
122  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4,
123  Dim2, i, j, k, l, m, k, Dim0, Dim1, Dim3,
124  Dim2, Dim4, i, j, l, k, m>;
126  Dim3, Dim4, i, j, l, m>(TensorExpr(a, b));
127  }
128 
129  // B(m,k)*A(i,j,k,l)
130  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
131  int Dim3, int Dim4, char i, char j, char k, char l, char m>
132  auto
135  {
136  return a * b;
137  }
138 
139  // A(i,j,k,l)*B(j,m)
140  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
141  int Dim3, int Dim4, char i, char j, char k, char l, char m>
142  auto
145  {
146  using TensorExpr
147  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim1,
148  Dim4, i, j, k, l, j, m, Dim0, Dim2, Dim3,
149  Dim1, Dim4, i, k, l, j, m>;
151  Dim3, Dim4, i, k, l, m>(TensorExpr(a, b));
152  }
153 
154  // B(j,m)*A(i,j,k,l)
155  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
156  int Dim3, int Dim4, char i, char j, char k, char l, char m>
157  auto
160  {
161  return a * b;
162  }
163 
164  // A(i,j,k,l)*B(m,j)
165  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
166  int Dim3, int Dim4, char i, char j, char k, char l, char m>
167  auto
170  {
171  using TensorExpr
172  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4,
173  Dim1, i, j, k, l, m, j, Dim0, Dim2, Dim3,
174  Dim1, Dim4, i, k, l, j, m>;
176  Dim3, Dim4, i, k, l, m>(TensorExpr(a, b));
177  }
178 
179  // B(m,j)*A(i,j,k,l)
180  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
181  int Dim3, int Dim4, char i, char j, char k, char l, char m>
182  auto
185  {
186  return a * b;
187  }
188 
189  // A(i,j,k,l)*B(i,m)
190  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
191  int Dim3, int Dim4, char i, char j, char k, char l, char m>
192  auto
195  {
196  using TensorExpr
197  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim0,
198  Dim4, i, j, k, l, i, m, Dim1, Dim2, Dim3,
199  Dim0, Dim4, j, k, l, i, m>;
201  Dim3, Dim4, j, k, l, m>(TensorExpr(a, b));
202  }
203 
204  // B(i,m)*A(i,j,k,l)
205  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
206  int Dim3, int Dim4, char i, char j, char k, char l, char m>
207  auto
210  {
211  return a * b;
212  }
213 
214  // A(i,j,k,l)*B(m,i)
215  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
216  int Dim3, int Dim4, char i, char j, char k, char l, char m>
217  auto
220  {
221  using TensorExpr
222  = Tensor4_times_Tensor2_single<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4,
223  Dim0, i, j, k, l, m, i, Dim1, Dim2, Dim3,
224  Dim0, Dim4, j, k, l, i, m>;
226  Dim3, Dim4, j, k, l, m>(TensorExpr(a, b));
227  }
228 
229  // B(m,i)*A(i,j,k,l)
230  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
231  int Dim3, int Dim4, char i, char j, char k, char l, char m>
232  auto
235  {
236  return a * b;
237  }
238 }
FTensor::Permutation2::eval
U eval(const Tensor2_Expr< B, U, Dim0, Dim1, i, j > &rhs, const int N0, const int N1)
Definition: Permutation2.hpp:12
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::Tensor2_Expr< B, U, Dim4, Dim5, m, n >
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
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
FTensor::Tensor4_Expr
Definition: Tensor4_Expr.hpp:25
FTensor::Tensor4_times_Tensor2_single::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Tensor4_times_Tensor2_single.hpp:17
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor4_times_Tensor2_single::iterB
Tensor2_Expr< B, U, Dim4, Dim5, m, n > iterB
Definition: Tensor4_times_Tensor2_single.hpp:13
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_times_Tensor2_single::iterA
Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor2_single.hpp:12
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
convert.n
n
Definition: convert.py:82
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Permutation2
Definition: Permutation2.hpp:7
FTensor::Tensor4_times_Tensor2_single
Definition: Tensor4_times_Tensor2_single.hpp:10
FTensor::Tensor4_times_Tensor2_single::Tensor4_times_Tensor2_single
Tensor4_times_Tensor2_single(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &iter_a, const Tensor2_Expr< B, U, Dim4, Dim5, m, n > &iter_b)
Definition: Tensor4_times_Tensor2_single.hpp:30
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