v0.14.0
Tensor2_symmetric_times_Tensor2_symmetric.hpp
Go to the documentation of this file.
1 /* This file has all of the declarations for
2  Tensor2_symmetric*Tensor2_symmetric. This includes the double
3  contraction A(i,j)*B(i,j) (yielding a typename promote<T,U>::V) as well as
4  the more complicated single contraction A(i,j)*B(j,k) (yielding a Tensor2
5  expression), and no contractions A(i,j)*B(k,l) -> Ddg */
6 
7 #pragma once
8 
9 namespace FTensor
10 {
11  /* Double contraction. */
12 
13  /* A(i,j)*B(i,j) */
14 
15  template <class A, class B, class T, class U, int Dim, char i, char j,
16  int Current_Dim0, int Current_Dim1>
17  typename promote<T, U>::V
21  {
22  return a(Current_Dim0 - 1, Current_Dim1 - 1)
23  * b(Current_Dim0 - 1, Current_Dim1 - 1)
26  }
27 
28  template <class A, class B, class T, class U, int Dim, char i, char j,
29  int Current_Dim1>
30  typename promote<T, U>::V
33  const Number<1> &, const Number<Current_Dim1> &)
34  {
35  return a(0, Current_Dim1 - 1) * b(0, Current_Dim1 - 1)
37  }
38 
39  template <class A, class B, class T, class U, int Dim, char i, char j>
40  typename promote<T, U>::V
43  const Number<1> &, const Number<1> &)
44  {
45  return a(0, 0) * b(0, 0);
46  }
47 
48  template <class A, class B, class T, class U, int Dim, char i, char j>
49  typename promote<T, U>::V
52  {
53  return T2s_times_T2s(a, b, Number<Dim>(), Number<Dim>());
54  }
55 
56  /* A(i,j)*B(j,i) */
57 
58  template <class A, class B, class T, class U, int Dim, char i, char j,
59  int Current_Dim0, int Current_Dim1>
60  typename promote<T, U>::V
63  const Number<Current_Dim0> &,
64  const Number<Current_Dim1> &)
65  {
66  return a(Current_Dim0 - 1, Current_Dim1 - 1)
67  * b(Current_Dim1 - 1, Current_Dim0 - 1)
70  }
71 
72  template <class A, class B, class T, class U, int Dim, char i, char j,
73  int Current_Dim1>
74  typename promote<T, U>::V
77  const Number<1> &, const Number<Current_Dim1> &)
78  {
79  return a(0, Current_Dim1 - 1) * b(Current_Dim1 - 1, 0)
82  }
83 
84  template <class A, class B, class T, class U, int Dim, char i, char j>
85  typename promote<T, U>::V
88  const Number<1> &, const Number<1> &)
89  {
90  return a(0, 0) * b(0, 0);
91  }
92 
93  template <class A, class B, class T, class U, int Dim, char i, char j>
94  typename promote<T, U>::V
97  {
99  }
100 
101  /* Single contraction. The wrapper class has a different name for
102  each possible placing of the indices (e.g. A(i,j)*B(j,k) has the
103  number 10 because the contraction indices are on the second and
104  first slots (counting from 0). */
105 
106  /* A(i,j)*B(j,k) */
107 
108  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
110  {
113 
114  template <int Current_Dim>
115  typename promote<T, U>::V
116  eval(const int N1, const int N2, const Number<Current_Dim> &) const
117  {
118  return iterA(N1, Current_Dim - 1) * iterB(Current_Dim - 1, N2)
119  + eval(N1, N2, Number<Current_Dim - 1>());
120  }
121  typename promote<T, U>::V
122  eval(const int N1, const int N2, const Number<1> &) const
123  {
124  return iterA(N1, 0) * iterB(0, N2);
125  }
126 
127  public:
131  : iterA(a), iterB(b)
132  {}
133  typename promote<T, U>::V operator()(const int N1, const int N2) const
134  {
135  return eval(N1, N2, Number<Dim>());
136  }
137  };
138 
139  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
140  Tensor2_Expr<
141  Tensor2_symmetric_times_Tensor2_symmetric_10<A, B, T, U, Dim, i, j, k>,
142  typename promote<T, U>::V, Dim, Dim, i, k>
145  {
146  using TensorExpr
149  TensorExpr(a, b));
150  }
151 
152  /* A(i,j)*B(k,j) */
153 
154  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
156  {
159 
160  template <int Current_Dim>
161  typename promote<T, U>::V
162  eval(const int N1, const int N2, const Number<Current_Dim> &) const
163  {
164  return iterA(N1, Current_Dim - 1) * iterB(N2, Current_Dim - 1)
165  + eval(N1, N2, Number<Current_Dim - 1>());
166  }
167  typename promote<T, U>::V
168  eval(const int N1, const int N2, const Number<1> &) const
169  {
170  return iterA(N1, 0) * iterB(N2, 0);
171  }
172 
173  public:
177  : iterA(a), iterB(b)
178  {}
179  typename promote<T, U>::V operator()(const int N1, const int N2) const
180  {
181  return eval(N1, N2, Number<Dim>());
182  }
183  };
184 
185  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
186  Tensor2_Expr<
187  Tensor2_symmetric_times_Tensor2_symmetric_11<A, B, T, U, Dim, i, j, k>,
188  typename promote<T, U>::V, Dim, Dim, i, k>
191  {
192  using TensorExpr
195  TensorExpr(a, b));
196  }
197 
198  /* A(j,i)*B(j,k) */
199 
200  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
202  {
205 
206  template <int Current_Dim>
207  typename promote<T, U>::V
208  eval(const int N1, const int N2, const Number<Current_Dim> &) const
209  {
210  return iterA(Current_Dim - 1, N1) * iterB(Current_Dim - 1, N2)
211  + eval(N1, N2, Number<Current_Dim - 1>());
212  }
213  typename promote<T, U>::V
214  eval(const int N1, const int N2, const Number<1> &) const
215  {
216  return iterA(0, N1) * iterB(0, N2);
217  }
218 
219  public:
223  : iterA(a), iterB(b)
224  {}
225  typename promote<T, U>::V operator()(const int N1, const int N2) const
226  {
227  return eval(N1, N2, Number<Dim>());
228  }
229  };
230 
231  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
232  Tensor2_Expr<
233  Tensor2_symmetric_times_Tensor2_symmetric_00<A, B, T, U, Dim, i, j, k>,
234  typename promote<T, U>::V, Dim, Dim, i, k>
237  {
238  using TensorExpr
241  TensorExpr(a, b));
242  }
243 
244  /* A(j,i)*B(k,j) */
245 
246  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
248  {
251 
252  template <int Current_Dim>
253  typename promote<T, U>::V
254  eval(const int N1, const int N2, const Number<Current_Dim> &) const
255  {
256  return iterA(Current_Dim - 1, N1) * iterB(N2, Current_Dim - 1)
257  + eval(N1, N2, Number<Current_Dim - 1>());
258  }
259  typename promote<T, U>::V
260  eval(const int N1, const int N2, const Number<1> &) const
261  {
262  return iterA(0, N1) * iterB(N2, 0);
263  }
264 
265  public:
269  : iterA(a), iterB(b)
270  {}
271  typename promote<T, U>::V operator()(const int N1, const int N2) const
272  {
273  return eval(N1, N2, Number<Dim>());
274  }
275  };
276 
277  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
278  Tensor2_Expr<
279  Tensor2_symmetric_times_Tensor2_symmetric_01<A, B, T, U, Dim, i, j, k>,
280  typename promote<T, U>::V, Dim, Dim, i, k>
283  {
284  using TensorExpr
287  TensorExpr(a, b));
288  }
289 
290  /* A(i,j)*B(k,l) -> Ddg */
291 
292  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
293  char j, char k, char l>
295  {
298 
299  public:
303  : iterA(a), iterB(b)
304  {}
305  typename promote<T, U>::V
306  operator()(const int N1, const int N2, const int N3, const int N4) const
307  {
308  return iterA(N1, N2) * iterB(N3, N4);
309  }
310  };
311 
312  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
313  char j, char k, char l>
314  Ddg_Expr<Tensor2_symmetric_times_Tensor2_symmetric<A, B, T, U, Dim0, Dim1, i,
315  j, k, l>,
316  typename promote<T, U>::V, Dim0, Dim1, i, j, k, l>
319  {
320  using TensorExpr
321  = Tensor2_symmetric_times_Tensor2_symmetric<A, B, T, U, Dim0, Dim1, i, j,
322  k, l>;
323  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim0, Dim1, i, j, k,
324  l>(TensorExpr(a, b));
325  }
326 }
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01::iterB
Tensor2_symmetric_Expr< B, U, Dim, k, j > iterB
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:250
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:254
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_symmetric_times_Tensor2_symmetric
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:294
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_symmetric_times_Tensor2_symmetric_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:260
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01::Tensor2_symmetric_times_Tensor2_symmetric_01
Tensor2_symmetric_times_Tensor2_symmetric_01(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_symmetric_Expr< B, U, Dim, k, j > &b)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:266
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:155
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:122
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:201
FTensor::Ddg_Expr
Definition: Ddg_Expr.hpp:28
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:208
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01::iterA
Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:249
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::Tensor2_symmetric_times_Tensor2_symmetric_00
Tensor2_symmetric_times_Tensor2_symmetric_00(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_symmetric_Expr< B, U, Dim, j, k > &b)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:220
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::Tensor2_symmetric_times_Tensor2_symmetric_10
Tensor2_symmetric_times_Tensor2_symmetric_10(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_symmetric_Expr< B, U, Dim, j, k > &b)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:128
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:179
FTensor::Number
Definition: Number.hpp:11
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::iterB
Tensor2_symmetric_Expr< B, U, Dim, j, k > iterB
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:112
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:225
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::iterA
Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:203
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:109
FTensor::Tensor2_symmetric_times_Tensor2_symmetric::Tensor2_symmetric_times_Tensor2_symmetric
Tensor2_symmetric_times_Tensor2_symmetric(const Tensor2_symmetric_Expr< A, T, Dim0, i, j > &a, const Tensor2_symmetric_Expr< B, U, Dim1, k, l > &b)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:300
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:116
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::Tensor2_symmetric_times_Tensor2_symmetric_11
Tensor2_symmetric_times_Tensor2_symmetric_11(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_symmetric_Expr< B, U, Dim, k, j > &b)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:174
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::T2s_times_switched_T2s
promote< T, U >::V T2s_times_switched_T2s(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_symmetric_Expr< B, U, Dim, j, i > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:61
FTensor::Tensor2_symmetric_times_Tensor2_symmetric::iterB
Tensor2_symmetric_Expr< B, U, Dim1, k, l > iterB
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:297
FTensor::Tensor2_symmetric_times_Tensor2_symmetric::iterA
Tensor2_symmetric_Expr< A, T, Dim0, i, j > iterA
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:296
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:214
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:271
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:133
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:162
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_01
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:247
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:157
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:168
FTensor::Tensor2_symmetric_times_Tensor2_symmetric::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:306
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_11::iterB
Tensor2_symmetric_Expr< B, U, Dim, k, j > iterB
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:158
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_10::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:111
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
FTensor::Tensor2_symmetric_times_Tensor2_symmetric_00::iterB
Tensor2_symmetric_Expr< B, U, Dim, j, k > iterB
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:204
FTensor::T2s_times_T2s
promote< T, U >::V T2s_times_T2s(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_times_Tensor2_symmetric.hpp:18