v0.14.0
Dg_times_Dg.hpp
Go to the documentation of this file.
1 /* This file has all of the declarations for expressions like
2  Dg*Dg yielding a Tensor2 or Ddg. */
3 
4 #pragma once
5 
6 namespace FTensor
7 {
8  /* A(i,j,k)*B(j,k,l) */
9 
10  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
11  char j, char k, char l>
13  {
16 
17  template <int Current_Dim0, int Current_Dim1>
18  typename promote<T, U>::V
19  eval(const int N1, const int N2, const Number<Current_Dim0> &,
20  const Number<Current_Dim1> &) const
21  {
22  return iterA(N1, Current_Dim0 - 1, Current_Dim1 - 1)
23  * iterB(Current_Dim0 - 1, Current_Dim1 - 1, N2)
24  + eval(N1, N2, Number<Current_Dim0 - 1>(),
26  }
27  template <int Current_Dim1>
28  typename promote<T, U>::V
29  eval(const int N1, const int N2, const Number<1> &,
30  const Number<Current_Dim1> &) const
31  {
32  return iterA(N1, 0, Current_Dim1 - 1) * iterB(0, Current_Dim1 - 1, N2)
34  }
35  typename promote<T, U>::V eval(const int N1, const int N2,
36  const Number<1> &, const Number<1> &) const
37  {
38  return iterA(N1, 0, 0) * iterB(0, 0, N2);
39  }
40 
41  public:
44  : iterA(a), iterB(b)
45  {}
46  typename promote<T, U>::V operator()(const int N1, const int N2) const
47  {
48  return eval(N1, N2, Number<Dim01>(), Number<Dim01>());
49  }
50  };
51 
52  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
53  char j, char k, char l>
54  Tensor2_Expr<Dg_times_Dg_12_01<A, B, T, U, Dim01, Dim2, i, j, k, l>,
55  typename promote<T, U>::V, Dim01, Dim2, i, l>
58  {
61  l>(TensorExpr(a, b));
62  }
63 
64  /* B(j,k,l)*A(i,j,k) */
65 
66  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
67  char j, char k, char l>
68  Tensor2_Expr<Dg_times_Dg_12_01<A, B, T, U, Dim01, Dim2, i, j, k, l>,
69  typename promote<T, U>::V, Dim01, Dim2, i, l>
72  {
75  l>(TensorExpr(a, b));
76  }
77 
78  /* A(i,j,k)*B(k,l,j) */
79 
80  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
81  char j, char k, char l>
83  {
86 
87  template <int Current_Dim0, int Current_Dim1>
88  typename promote<T, U>::V
89  eval(const int N1, const int N2, const Number<Current_Dim0> &,
90  const Number<Current_Dim1> &) const
91  {
92  return iterA(N1, Current_Dim0 - 1, Current_Dim1 - 1)
93  * iterB(Current_Dim1 - 1, N2, Current_Dim0 - 1)
94  + eval(N1, N2, Number<Current_Dim0 - 1>(),
96  }
97  template <int Current_Dim1>
98  typename promote<T, U>::V
99  eval(const int N1, const int N2, const Number<1> &,
100  const Number<Current_Dim1> &) const
101  {
102  return iterA(N1, 0, Current_Dim1 - 1) * iterB(Current_Dim1 - 1, N2, 0)
104  }
105  typename promote<T, U>::V eval(const int N1, const int N2,
106  const Number<1> &, const Number<1> &) const
107  {
108  return iterA(N1, 0, 0) * iterB(0, N2, 0);
109  }
110 
111  public:
114  : iterA(a), iterB(b)
115  {}
116  typename promote<T, U>::V operator()(const int N1, const int N2) const
117  {
118  return eval(N1, N2, Number<Dim01>(), Number<Dim2>());
119  }
120  };
121 
122  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
123  char j, char k, char l>
124  Tensor2_Expr<Dg_times_Dg_12_20<A, B, T, U, Dim01, Dim2, i, j, k, l>,
125  typename promote<T, U>::V, Dim01, Dim2, i, l>
128  {
131  l>(TensorExpr(a, b));
132  }
133 
134  /* B(k,l,j)*A(i,j,k) */
135 
136  template <class A, class B, class T, class U, int Dim01, int Dim2, char i,
137  char j, char k, char l>
138  Tensor2_Expr<Dg_times_Dg_12_20<A, B, T, U, Dim01, Dim2, i, j, k, l>,
139  typename promote<T, U>::V, Dim01, Dim2, i, l>
142  {
145  l>(TensorExpr(a, b));
146  }
147 
148  /* A(i,j,k)*B(i,j,k) */
149 
150  template <class A, class B, class T, class U, int Dim01, int Dim2, int Dim3,
151  char i, char j, char k, char l>
155 
156  template <int Current_Dim0, int Current_Dim1>
157  typename promote<T, U>::V eval(const int N1, const int N2,
158  const Number<Current_Dim0> &,
159  const Number<Current_Dim1> &) const {
160  return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1) *
161  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N2) +
163  }
164  template <int Current_Dim1>
165  typename promote<T, U>::V eval(const int N1, const int N2,
166  const Number<1> &,
167  const Number<Current_Dim1> &) const {
168  return iterA(0, Current_Dim1 - 1, N1) * iterB(0, Current_Dim1 - 1, N2) +
170  }
171  typename promote<T, U>::V eval(const int N1, const int N2,
172  const Number<1> &, const Number<1> &) const {
173  return iterA(0, 0, N1) * iterB(0, 0, N2);
174  }
175 
176  public:
179  : iterA(a), iterB(b) {}
180  typename promote<T, U>::V operator()(const int N1, const int N2) const {
181  return eval(N1, N2, Number<Dim01>(), Number<Dim01>());
182  }
183  };
184 
185  template <class A, class B, class T, class U, int Dim01, int Dim2, int Dim3,
186  char i, char j, char k, char l>
189  using TensorExpr =
192  l>(TensorExpr(a, b));
193  }
194 
195  /* A(i,j,k)*B(l,m,k) -> Ddg */
196 
197  template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim2,
198  char i, char j, char k, char l, char m>
200  {
203 
204  template <int Current_Dim0>
205  typename promote<T, U>::V
206  eval(const int N1, const int N2, const int N3, const int N4,
207  const Number<Current_Dim0> &) const
208  {
209  return iterA(N1, N2, Current_Dim0 - 1) * iterB(N3, N4, Current_Dim0 - 1)
210  + eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>());
211  }
212  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
213  const int N4, const Number<1> &) const
214  {
215  return iterA(N1, N2, 0) * iterB(N3, N4, 0);
216  }
217 
218  public:
221  : iterA(a), iterB(b)
222  {}
223  typename promote<T, U>::V
224  operator()(const int N1, const int N2, const int N3, const int N4) const
225  {
226  return eval(N1, N2, N3, N4, Number<Dim2>());
227  }
228  };
229 
230  template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim2,
231  char i, char j, char k, char l, char m>
232  Ddg_Expr<Dg_times_Dg_2<A, B, T, U, Dim01, Dim23, Dim2, i, j, k, l, m>,
233  typename promote<T, U>::V, Dim01, Dim23, i, j, l, m>
236  {
237  using TensorExpr
239  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j,
240  l, m>(TensorExpr(a, b));
241  }
242 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Dg_times_Dg_12_01::iterA
Dg_Expr< A, T, Dim01, Dim01, i, j, k > iterA
Definition: Dg_times_Dg.hpp:14
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::Dg_times_Dg_2::Dg_times_Dg_2
Dg_times_Dg_2(const Dg_Expr< A, T, Dim01, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim23, Dim2, l, m, k > &b)
Definition: Dg_times_Dg.hpp:219
FTensor::Dg_times_Dg_12_20::iterB
Dg_Expr< B, U, Dim2, Dim01, k, l, j > iterB
Definition: Dg_times_Dg.hpp:85
FTensor::Dg_times_Dg_01_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:157
FTensor::Dg_times_Dg_01_01::iterA
Dg_Expr< A, T, Dim01, Dim2, i, j, k > iterA
Definition: Dg_times_Dg.hpp:153
FTensor::Dg_times_Dg_12_20::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:89
FTensor::Dg_times_Dg_12_01::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Dg_times_Dg.hpp:46
FTensor::Dg_times_Dg_12_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:19
FTensor::Dg_times_Dg_12_01
Definition: Dg_times_Dg.hpp:12
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
FTensor::Dg_times_Dg_01_01::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Dg_times_Dg.hpp:180
FTensor::Dg_times_Dg_12_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< 1 > &) const
Definition: Dg_times_Dg.hpp:35
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Dg_times_Dg_12_20
Definition: Dg_times_Dg.hpp:82
FTensor::Ddg_Expr
Definition: Ddg_Expr.hpp:28
FTensor::Dg_times_Dg_12_01::Dg_times_Dg_12_01
Dg_times_Dg_12_01(const Dg_Expr< A, T, Dim01, Dim01, i, j, k > &a, const Dg_Expr< B, U, Dim01, Dim2, j, k, l > &b)
Definition: Dg_times_Dg.hpp:42
FTensor::Dg_times_Dg_2::iterB
Dg_Expr< B, U, Dim23, Dim2, l, m, k > iterB
Definition: Dg_times_Dg.hpp:202
FTensor::Dg_times_Dg_01_01::iterB
Dg_Expr< B, U, Dim01, Dim3, i, j, l > iterB
Definition: Dg_times_Dg.hpp:154
FTensor::Dg_times_Dg_12_20::Dg_times_Dg_12_20
Dg_times_Dg_12_20(const Dg_Expr< A, T, Dim01, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim2, Dim01, k, l, j > &b)
Definition: Dg_times_Dg.hpp:112
FTensor::Dg_times_Dg_01_01
Definition: Dg_times_Dg.hpp:152
FTensor::Number
Definition: Number.hpp:11
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Dg_times_Dg_12_01::iterB
Dg_Expr< B, U, Dim01, Dim2, j, k, l > iterB
Definition: Dg_times_Dg.hpp:15
FTensor::Dg_times_Dg_12_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:29
FTensor::Dg_times_Dg_12_20::iterA
Dg_Expr< A, T, Dim01, Dim2, i, j, k > iterA
Definition: Dg_times_Dg.hpp:84
FTensor::Dg_times_Dg_2::iterA
Dg_Expr< A, T, Dim01, Dim2, i, j, k > iterA
Definition: Dg_times_Dg.hpp:201
FTensor::Dg_times_Dg_12_20::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< 1 > &) const
Definition: Dg_times_Dg.hpp:105
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Dg_times_Dg_12_20::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Dg_times_Dg.hpp:116
FTensor::Dg_times_Dg_01_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< 1 > &) const
Definition: Dg_times_Dg.hpp:171
FTensor::Dg_times_Dg_2::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Dg_times_Dg.hpp:224
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Dg_times_Dg_2::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &) const
Definition: Dg_times_Dg.hpp:206
FTensor::Dg_times_Dg_12_20::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:99
FTensor::Dg_times_Dg_01_01::Dg_times_Dg_01_01
Dg_times_Dg_01_01(const Dg_Expr< A, T, Dim01, Dim2, i, j, k > &a, const Dg_Expr< B, U, Dim01, Dim3, i, j, l > &b)
Definition: Dg_times_Dg.hpp:177
FTensor::Dg_Expr< A, T, Dim01, Dim01, i, j, k >
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
FTensor::Dg_times_Dg_2::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &) const
Definition: Dg_times_Dg.hpp:212
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Dg_times_Dg_2
Definition: Dg_times_Dg.hpp:199
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
FTensor::Dg_times_Dg_01_01::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Dg_times_Dg.hpp:165