v0.14.0
Tensor2_symmetric_times_Tensor2.hpp
Go to the documentation of this file.
1 /* This file has all of the declarations for
2  Tensor2_symmetric*Tensor2. This includes the double
3  contraction A(i,j)*B(i,j) (yielding a double) as well as the more
4  complicated single contraction A(i,j)*B(j,k) (yielding a Tensor2
5  expression). */
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_T2_01(a, b, Number<Dim>(), Number<Dim>());
54  }
55 
56  /* B(i,j)*A(i,j) */
57 
58  template <class A, class B, class T, class U, int Dim, char i, char j>
59  typename promote<T, U>::V
62 
63  {
64  return T2s_times_T2_01(a, b, Number<Dim>(), Number<Dim>());
65  }
66 
67  /* Double contraction with switched indices. The perspicacious reader
68  will note that it just replicated code for the aligned indices case
69  above, but with B(i,j) -> B(j,i). This is ok, since A is
70  symmetric. */
71 
72  /* A(i,j)*B(j,i) */
73 
74  template <class A, class B, class T, class U, int Dim, char i, char j,
75  int Current_Dim0, int Current_Dim1>
76  typename promote<T, U>::V
80  {
81  return a(Current_Dim0 - 1, Current_Dim1 - 1)
82  * b(Current_Dim0 - 1, Current_Dim1 - 1)
85  }
86 
87  template <class A, class B, class T, class U, int Dim, char i, char j,
88  int Current_Dim1>
89  typename promote<T, U>::V
92  const Number<1> &, const Number<Current_Dim1> &)
93  {
94  return a(0, Current_Dim1 - 1) * b(0, Current_Dim1 - 1)
96  }
97 
98  template <class A, class B, class T, class U, int Dim, char i, char j>
99  typename promote<T, U>::V
102  const Number<1> &, const Number<1> &)
103  {
104  return a(0, 0) * b(0, 0);
105  }
106 
107  template <class A, class B, class T, class U, int Dim, char i, char j>
108  typename promote<T, U>::V
111  {
112  return T2s_times_T2_01(a, b, Number<Dim>(), Number<Dim>());
113  }
114 
115  /* B(j,i)*A(i,j) */
116 
117  template <class A, class B, class T, class U, int Dim, char i, char j>
118  typename promote<T, U>::V
121 
122  {
123  return T2s_times_T2_01(a, b, Number<Dim>(), Number<Dim>());
124  }
125 
126  /* Single contraction. The wrapper class has a different name for
127  each possible placing of the indices (e.g. A(i,j)*B(j,k) has the
128  number 10 because the contraction indices are on the second and
129  first slots (counting from 0). */
130 
131  /* A(i,j)*B(j,k) */
132 
133  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
134  char j, char k>
136  {
139 
140  template <int Current_Dim>
141  typename promote<T, U>::V
142  eval(const int N1, const int N2, const Number<Current_Dim> &) const
143  {
144  return iterA(N1, Current_Dim - 1) * iterB(Current_Dim - 1, N2)
145  + eval(N1, N2, Number<Current_Dim - 1>());
146  }
147  typename promote<T, U>::V
148  eval(const int N1, const int N2, const Number<1> &) const
149  {
150  return iterA(N1, 0) * iterB(0, N2);
151  }
152 
153  public:
157  : iterA(a), iterB(b)
158  {}
159  typename promote<T, U>::V operator()(const int N1, const int N2) const
160  {
161  return eval(N1, N2, Number<Dim>());
162  }
163  };
164 
165  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
166  char j, char k>
167  Tensor2_Expr<
168  Tensor2_symmetric_times_Tensor2_10<A, B, T, U, Dim, Dim1, i, j, k>,
169  typename promote<T, U>::V, Dim, Dim1, i, k>
172  {
173  using TensorExpr
176  TensorExpr(a, b));
177  }
178 
179  /* B(j,k)*A(i,j) */
180 
181  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
182  char j, char k>
183  Tensor2_Expr<
184  Tensor2_symmetric_times_Tensor2_10<A, B, T, U, Dim, Dim1, i, j, k>,
185  typename promote<T, U>::V, Dim, Dim1, i, k>
188  {
189  using TensorExpr
192  TensorExpr(a, b));
193  }
194 
195  /* A(i,j)*B(k,j) */
196 
197  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
198  char j, char k>
200  {
203 
204  template <int Current_Dim>
205  typename promote<T, U>::V
206  eval(const int N1, const int N2, const Number<Current_Dim> &) const
207  {
208  return iterA(N1, Current_Dim - 1) * iterB(N2, Current_Dim - 1)
209  + eval(N1, N2, Number<Current_Dim - 1>());
210  }
211  typename promote<T, U>::V
212  eval(const int N1, const int N2, const Number<1> &) const
213  {
214  return iterA(N1, 0) * iterB(N2, 0);
215  }
216 
217  public:
221  : iterA(a), iterB(b)
222  {}
223  typename promote<T, U>::V operator()(const int N1, const int N2) const
224  {
225  return eval(N1, N2, Number<Dim>());
226  }
227  };
228 
229  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
230  char j, char k>
231  Tensor2_Expr<
232  Tensor2_symmetric_times_Tensor2_11<A, B, T, U, Dim, Dim1, i, j, k>,
233  typename promote<T, U>::V, Dim, Dim1, i, k>
236  {
237  using TensorExpr
240  TensorExpr(a, b));
241  }
242 
243  /* B(k,j)*A(i,j) */
244 
245  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
246  char j, char k>
247  Tensor2_Expr<
248  Tensor2_symmetric_times_Tensor2_11<A, B, T, U, Dim, Dim1, i, j, k>,
249  typename promote<T, U>::V, Dim, Dim1, i, k>
252  {
253  using TensorExpr
256  TensorExpr(a, b));
257  }
258 
259  /* A(j,i)*B(j,k) */
260 
261  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
262  char j, char k>
264  {
267 
268  template <int Current_Dim>
269  typename promote<T, U>::V
270  eval(const int N1, const int N2, const Number<Current_Dim> &) const
271  {
272  return iterA(Current_Dim - 1, N1) * iterB(Current_Dim - 1, N2)
273  + eval(N1, N2, Number<Current_Dim - 1>());
274  }
275  typename promote<T, U>::V
276  eval(const int N1, const int N2, const Number<1> &) const
277  {
278  return iterA(0, N1) * iterB(0, N2);
279  }
280 
281  public:
285  : iterA(a), iterB(b)
286  {}
287  typename promote<T, U>::V operator()(const int N1, const int N2) const
288  {
289  return eval(N1, N2, Number<Dim>());
290  }
291  };
292 
293  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
294  char j, char k>
295  Tensor2_Expr<
296  Tensor2_symmetric_times_Tensor2_00<A, B, T, U, Dim, Dim1, i, j, k>,
297  typename promote<T, U>::V, Dim, Dim1, i, k>
300  {
301  using TensorExpr
304  TensorExpr(a, b));
305  }
306 
307  /* B(j,k)*A(j,i) */
308 
309  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
310  char j, char k>
311  Tensor2_Expr<
312  Tensor2_symmetric_times_Tensor2_00<A, B, T, U, Dim, Dim1, i, j, k>,
313  typename promote<T, U>::V, Dim, Dim1, i, k>
316  {
317  using TensorExpr
320  TensorExpr(a, b));
321  }
322 
323  /* A(j,i)*B(k,j) */
324 
325  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
326  char j, char k>
328  {
331 
332  template <int Current_Dim>
333  typename promote<T, U>::V
334  eval(const int N1, const int N2, const Number<Current_Dim> &) const
335  {
336  return iterA(Current_Dim - 1, N1) * iterB(N2, Current_Dim - 1)
337  + eval(N1, N2, Number<Current_Dim - 1>());
338  }
339  typename promote<T, U>::V
340  eval(const int N1, const int N2, const Number<1> &) const
341  {
342  return iterA(0, N1) * iterB(N2, 0);
343  }
344 
345  public:
349  : iterA(a), iterB(b)
350  {}
351  typename promote<T, U>::V operator()(const int N1, const int N2) const
352  {
353  return eval(N1, N2, Number<Dim>());
354  }
355  };
356 
357  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
358  char j, char k>
359  Tensor2_Expr<
360  Tensor2_symmetric_times_Tensor2_01<A, B, T, U, Dim, Dim1, i, j, k>,
361  typename promote<T, U>::V, Dim, Dim1, i, k>
364  {
365  using TensorExpr
368  TensorExpr(a, b));
369  }
370 
371  /* B(k,j)*A(j,i) */
372 
373  template <class A, class B, class T, class U, int Dim, int Dim1, char i,
374  char j, char k>
375  Tensor2_Expr<
376  Tensor2_symmetric_times_Tensor2_01<A, B, T, U, Dim, Dim1, i, j, k>,
377  typename promote<T, U>::V, Dim, Dim1, i, k>
380  {
381  using TensorExpr
384  TensorExpr(a, b));
385  }
386 }
FTensor::Tensor2_symmetric_times_Tensor2_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:340
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_symmetric_times_Tensor2_11::iterB
Tensor2_Expr< B, U, Dim1, Dim, k, j > iterB
Definition: Tensor2_symmetric_times_Tensor2.hpp:202
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_10
Definition: Tensor2_symmetric_times_Tensor2.hpp:135
FTensor::Tensor2_symmetric_times_Tensor2_11::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:212
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::Tensor2_symmetric_times_Tensor2_10::iterB
Tensor2_Expr< B, U, Dim, Dim1, j, k > iterB
Definition: Tensor2_symmetric_times_Tensor2.hpp:138
FTensor::Tensor2_symmetric_times_Tensor2_10::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:148
FTensor::Tensor2_symmetric_times_Tensor2_11::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_times_Tensor2.hpp:201
FTensor::Tensor2_Expr< B, U, Dim, Dim, i, j >
FTensor::Tensor2_symmetric_times_Tensor2_01
Definition: Tensor2_symmetric_times_Tensor2.hpp:327
FTensor::Tensor2_symmetric_times_Tensor2_00::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:287
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_symmetric_times_Tensor2_11::Tensor2_symmetric_times_Tensor2_11
Tensor2_symmetric_times_Tensor2_11(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim1, Dim, k, j > &b)
Definition: Tensor2_symmetric_times_Tensor2.hpp:218
FTensor::Tensor2_symmetric_times_Tensor2_01::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:351
FTensor::Tensor2_symmetric_times_Tensor2_11::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:223
FTensor::Tensor2_symmetric_times_Tensor2_01::Tensor2_symmetric_times_Tensor2_01
Tensor2_symmetric_times_Tensor2_01(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim1, Dim, k, j > &b)
Definition: Tensor2_symmetric_times_Tensor2.hpp:346
FTensor::Number
Definition: Number.hpp:11
FTensor::Tensor2_symmetric_times_Tensor2_11::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:206
FTensor::Tensor2_symmetric_times_Tensor2_10::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:142
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor2_symmetric_times_Tensor2_01::iterB
Tensor2_Expr< B, U, Dim1, Dim, k, j > iterB
Definition: Tensor2_symmetric_times_Tensor2.hpp:330
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_symmetric_times_Tensor2_00::iterB
Tensor2_Expr< B, U, Dim, Dim1, j, k > iterB
Definition: Tensor2_symmetric_times_Tensor2.hpp:266
FTensor::Tensor2_symmetric_times_Tensor2_10::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_times_Tensor2.hpp:137
FTensor::Tensor2_symmetric_times_Tensor2_00
Definition: Tensor2_symmetric_times_Tensor2.hpp:263
FTensor::Tensor2_symmetric_times_Tensor2_00::Tensor2_symmetric_times_Tensor2_00
Tensor2_symmetric_times_Tensor2_00(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim, Dim1, j, k > &b)
Definition: Tensor2_symmetric_times_Tensor2.hpp:282
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor2_symmetric_times_Tensor2_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:334
FTensor::Tensor2_symmetric_times_Tensor2_00::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:276
FTensor::Tensor2_symmetric_times_Tensor2_00::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:270
FTensor::Tensor2_symmetric_times_Tensor2_11
Definition: Tensor2_symmetric_times_Tensor2.hpp:199
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_symmetric_times_Tensor2_10::Tensor2_symmetric_times_Tensor2_10
Tensor2_symmetric_times_Tensor2_10(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim1, j, k > &b)
Definition: Tensor2_symmetric_times_Tensor2.hpp:154
FTensor::Tensor2_symmetric_times_Tensor2_01::iterA
Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_times_Tensor2.hpp:329
FTensor::Tensor2_symmetric_times_Tensor2_10::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_times_Tensor2.hpp:159
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::T2s_times_T2_01
promote< T, U >::V T2s_times_T2_01(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, i, j > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_times_Tensor2.hpp:18
FTensor::Tensor2_symmetric_times_Tensor2_00::iterA
Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_times_Tensor2.hpp:265
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197