v0.14.0
Ddg_times_Ddg.hpp
Go to the documentation of this file.
1 /* Fully contract a Ddg with a Ddg. */
2 
3 #pragma once
4 
5 namespace FTensor {
6 /* A(i,j,k,l)*B(i,k,j,l) */
7 
8 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
9  char l, int Current_Dim0, int Current_Dim1, int Current_Dim2,
10  int Current_Dim3>
15  const Number<Current_Dim3> &) {
16  return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
17  Current_Dim3 - 1) *
18  b(Current_Dim0 - 1, Current_Dim2 - 1, Current_Dim1 - 1,
19  Current_Dim3 - 1) +
23 }
24 
25 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
26  char l, int Current_Dim1, int Current_Dim2, int Current_Dim3>
27 typename promote<T, U>::V
30  const Number<1> &, const Number<Current_Dim1> &,
31  const Number<Current_Dim2> &,
32  const Number<Current_Dim3> &) {
33  return a(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1) *
34  b(0, Current_Dim2 - 1, Current_Dim1 - 1, Current_Dim3 - 1) +
37 }
38 
39 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
40  char l, int Current_Dim2, int Current_Dim3>
41 typename promote<T, U>::V
44  const Number<1> &, const Number<1> &,
45  const Number<Current_Dim2> &,
46  const Number<Current_Dim3> &) {
47  return a(0, 0, Current_Dim2 - 1, Current_Dim3 - 1) *
48  b(0, Current_Dim2 - 1, 0, Current_Dim3 - 1) +
52 }
53 
54 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
55  char l, int Current_Dim3>
56 typename promote<T, U>::V
59  const Number<1> &, const Number<1> &, const Number<1> &,
60  const Number<Current_Dim3> &) {
61  return a(0, 0, 0, Current_Dim3 - 1) * b(0, 0, 0, Current_Dim3 - 1) +
64 }
65 
66 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
67  char l>
68 typename promote<T, U>::V
71  const Number<1> &, const Number<1> &, const Number<1> &,
72  const Number<1> &) {
73  return a(0, 0, 0, 0) * b(0, 0, 0, 0);
74 }
75 
76 template <class A, class B, class T, class U, int Dim, char i, char j, char k,
77  char l>
78 typename promote<T, U>::V
83 }
84 
85 /* A(m,n,i,j)*B(m,n,k,l) -> Ddg */
86 
87 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
88  char i, char j, char k, char l, char m, char n>
90 
93 
96 
97 public:
98  Ddg_times_Ddg_0101(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
99 
100  template <int Current_Dim0, int Current_Dim1>
101  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
102  const int N4, const Number<Current_Dim0> &,
103  const Number<Current_Dim1> &) const {
104  return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
105  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
106  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
108  }
109  template <int Current_Dim1>
110  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
111  const int N4, const Number<1> &,
112  const Number<Current_Dim1> &) const {
113  return iterA(0, Current_Dim1 - 1, N1, N2) *
114  iterB(0, Current_Dim1 - 1, N3, N4) +
115  eval(N1, N2, N3, N4, Number<Dim45>(),
117  }
118  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
119  const int N4, const Number<1> &,
120  const Number<1> &) const {
121  return iterA(0, 0, N1, N2) * iterB(0, 0, N3, N4);
122  }
123 
124  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
125  const int N4) const {
126  return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
127  }
128 };
129 
130 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
131  char i, char j, char k, char l, char m, char n>
134  using TensorExpr =
136  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
137  l>(TensorExpr(a, b));
138 }
139 
140 /* A(i,j, m, n)*B(m,n,k,l) -> Ddg */
141 
142 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
143  char i, char j, char k, char l, char m, char n>
145 
148 
151 
152 public:
153  Ddg_times_Ddg_2301(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
154 
155  template <int Current_Dim0, int Current_Dim1>
156  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
157  const int N4, const Number<Current_Dim0> &,
158  const Number<Current_Dim1> &) const {
159  return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
160  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
161  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
163  }
164  template <int Current_Dim1>
165  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
166  const int N4, const Number<1> &,
167  const Number<Current_Dim1> &) const {
168  return iterA(N1, N2, 0, Current_Dim1 - 1) *
169  iterB(0, Current_Dim1 - 1, N3, N4) +
170  eval(N1, N2, N3, N4, Number<Dim45>(), Number<Current_Dim1 - 1>());
171  }
172  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
173  const int N4, const Number<1> &,
174  const Number<1> &) const {
175  return iterA(N1, N2, 0, 0) * iterB(0, 0, N3, N4);
176  }
177 
178  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
179  const int N4) const {
180  return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
181  }
182 
183 };
184 
185 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
186  char i, char j, char k, char l, char m, char n>
187 Ddg_Expr<Ddg_times_Ddg_2301<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
188  typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
191  using TensorExpr =
193  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
194  l>(TensorExpr(a, b));
195 }
196 
197 /* A(m,n,i,j)*B(k,l,m,n) -> Ddg */
198 
199 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
200  char i, char j, char k, char l, char m, char n>
202 
205 
208 
209 public:
210  Ddg_times_Ddg_0123(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
211 
212  template <int Current_Dim0, int Current_Dim1>
213  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
214  const int N4, const Number<Current_Dim0> &,
215  const Number<Current_Dim1> &) const {
216  return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
217  iterB(N3, N4, Current_Dim0 - 1, Current_Dim1 - 1) +
218  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
220  }
221  template <int Current_Dim1>
222  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
223  const int N4, const Number<1> &,
224  const Number<Current_Dim1> &) const {
225  return iterA(0, Current_Dim1 - 1, N1, N2) *
226  iterB(N3, N4, 0, Current_Dim1 - 1) +
227  eval(N1, N2, N3, N4, Number<Dim45>(), Number<Current_Dim1 - 1>());
228  }
229  inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
230  const int N4, const Number<1> &,
231  const Number<1> &) const {
232  return iterA(0, 0, N1, N2) * iterB(N3, N4, 0, 0);
233  }
234 
235  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
236  const int N4) const {
237  return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
238  }
239 
240 
241 };
242 
243 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
244  char i, char j, char k, char l, char m, char n>
245 Ddg_Expr<Ddg_times_Ddg_0123<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
246  typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
249  using TensorExpr =
251  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
252  l>(TensorExpr(a, b));
253 }
254 
255 /* A(i,j,m,n)*B(k,l,m,n) -> Ddg */
256 
257 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
258  char i, char j, char k, char l, char m, char n>
260 
263 
266 
267 public:
268  Ddg_times_Ddg_2323(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
269 
270  template <int Current_Dim0, int Current_Dim1>
271  inline typename promote<T, U>::V
272  eval(const int N1, const int N2, const int N3, const int N4,
273  const Number<Current_Dim0> &, const Number<Current_Dim1> &) const {
274  return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
275  iterB(N3, N4, Current_Dim0 - 1, Current_Dim1 - 1) +
276  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
278  }
279  template <int Current_Dim1>
280  inline typename promote<T, U>::V
281  eval(const int N1, const int N2, const int N3, const int N4,
282  const Number<1> &, const Number<Current_Dim1> &) const {
283  return iterA(N1, N2, 0, Current_Dim1 - 1) *
284  iterB(N3, N4, 0, Current_Dim1 - 1) +
285  eval(N1, N2, N3, N4, Number<Dim45>(), Number<Current_Dim1 - 1>());
286  }
287  inline typename promote<T, U>::V eval(const int N1, const int N2,
288  const int N3, const int N4,
289  const Number<1> &,
290  const Number<1> &) const {
291  return iterA(N1, N2, 0, 0) * iterB(N3, N4, 0, 0);
292  }
293 
294  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
295  const int N4) const {
296  return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
297  }
298 
299 };
300 
301 template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
302  char i, char j, char k, char l, char m, char n>
303 Ddg_Expr<Ddg_times_Ddg_2323<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
304  typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
307  using TensorExpr =
309  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
310  l>(TensorExpr(a, b));
311 }
312 
313 } // namespace FTensor
FTensor::Ddg_times_Ddg_0123::Ddg_times_Ddg_0123
Ddg_times_Ddg_0123(const IterA &a, const IterB &b)
Definition: Ddg_times_Ddg.hpp:210
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::Ddg_times_Ddg_2323::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Ddg_times_Ddg.hpp:287
FTensor::Ddg_times_Ddg_0101::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_times_Ddg.hpp:124
FTensor::T4ddg_times_T4ddg_0213
promote< T, U >::V T4ddg_times_T4ddg_0213(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, k, j, l > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_times_Ddg.hpp:11
FTensor::Ddg_times_Ddg_0123::iterB
IterB iterB
Definition: Ddg_times_Ddg.hpp:207
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Ddg_times_Ddg_0123::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Ddg_times_Ddg.hpp:229
FTensor::Ddg_times_Ddg_2323::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:281
FTensor::Ddg_times_Ddg_0123
Definition: Ddg_times_Ddg.hpp:201
FTensor::Ddg_times_Ddg_0101::iterB
IterB iterB
Definition: Ddg_times_Ddg.hpp:95
FTensor::Ddg_Expr< A, T, Dim, Dim, i, j, k, l >
FTensor::Ddg_times_Ddg_2323::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:272
FTensor::Ddg_times_Ddg_0101::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Ddg_times_Ddg.hpp:118
FTensor::Number
Definition: Number.hpp:11
FTensor::Ddg_times_Ddg_2323
Definition: Ddg_times_Ddg.hpp:259
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Ddg_times_Ddg_2323::Ddg_times_Ddg_2323
Ddg_times_Ddg_2323(const IterA &a, const IterB &b)
Definition: Ddg_times_Ddg.hpp:268
FTensor::Ddg_times_Ddg_2323::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_times_Ddg.hpp:294
FTensor::Ddg_times_Ddg_2301::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:156
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Ddg_times_Ddg_2301::Ddg_times_Ddg_2301
Ddg_times_Ddg_2301(const IterA &a, const IterB &b)
Definition: Ddg_times_Ddg.hpp:153
FTensor::Ddg_times_Ddg_0101::Ddg_times_Ddg_0101
Ddg_times_Ddg_0101(const IterA &a, const IterB &b)
Definition: Ddg_times_Ddg.hpp:98
FTensor::Ddg_times_Ddg_0123::iterA
IterA iterA
Definition: Ddg_times_Ddg.hpp:206
FTensor::Ddg_times_Ddg_0101::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:101
FTensor::Ddg_times_Ddg_0101
Definition: Ddg_times_Ddg.hpp:89
FTensor::Ddg_times_Ddg_2301::iterB
IterB iterB
Definition: Ddg_times_Ddg.hpp:150
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
convert.n
n
Definition: convert.py:82
FTensor::Ddg_times_Ddg_0123::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_times_Ddg.hpp:235
FTensor::Ddg_times_Ddg_0101::iterA
IterA iterA
Definition: Ddg_times_Ddg.hpp:94
FTensor::Ddg_times_Ddg_2323::iterB
IterB iterB
Definition: Ddg_times_Ddg.hpp:265
FTensor::Ddg_times_Ddg_2301::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Ddg_times_Ddg.hpp:172
FTensor::Ddg_times_Ddg_2301
Definition: Ddg_times_Ddg.hpp:144
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Ddg_times_Ddg_2323::iterA
IterA iterA
Definition: Ddg_times_Ddg.hpp:264
FTensor::Ddg_times_Ddg_0101::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:110
FTensor::Ddg_times_Ddg_2301::iterA
IterA iterA
Definition: Ddg_times_Ddg.hpp:149
FTensor::Ddg_times_Ddg_2301::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:165
FTensor::Ddg_times_Ddg_0123::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:213
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
FTensor::Ddg_times_Ddg_2301::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_times_Ddg.hpp:178
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
FTensor::Ddg_times_Ddg_0123::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Ddg_times_Ddg.hpp:222