v0.14.0
Tensor4_times_Tensor1.hpp
Go to the documentation of this file.
1 /* Declarations for expressions like Tensor4*Tensor1 -> Tensor3 */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* A(i,j,k,l)*B(l) -> Tensor3 */
8 
9  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
10  int Dim3, char i, char j, char k, char l>
12  {
15 
16  template <int Current_Dim>
17  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
18  const Number<Current_Dim> &) const
19  {
20  return iterA(N1, N2, N3, Current_Dim - 1) * iterB(Current_Dim - 1)
21  + eval(N1, N2, N3, Number<Current_Dim - 1>());
22  }
23  typename promote<T, U>::V
24  eval(const int N1, const int N2, const int N3, const Number<1> &) const
25  {
26  return iterA(N1, N2, N3, 0) * iterB(0);
27  }
28 
29  public:
30  typename promote<T, U>::V
31  operator()(const int N1, const int N2, const int N3) const
32  {
33  return eval(N1, N2, N3, Number<Dim3>());
34  }
35 
39  : iterA(a), iterB(b)
40  {}
41  };
42 
43  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
44  int Dim3, char i, char j, char k, char l>
45  inline Tensor3_Expr<const Tensor4_times_Tensor1_3<A, B, T, U, Dim0, Dim1,
46  Dim2, Dim3, i, j, k, l>,
47  typename promote<T, U>::V, Dim0, Dim1, Dim2, i, j, k>
50  {
51  typedef const Tensor4_times_Tensor1_3<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
52  i, j, k, l>
53  TensorExpr;
55  Dim2, i, j, k>(TensorExpr(a, b));
56  }
57 
58  /* B(l)*A(i,j,k,l) -> Tensor3 */
59 
60  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
61  int Dim3, char i, char j, char k, char l>
62  inline Tensor3_Expr<const Tensor4_times_Tensor1_3<A, B, T, U, Dim0, Dim1,
63  Dim2, Dim3, i, j, k, l>,
64  typename promote<T, U>::V, Dim0, Dim1, Dim2, i, j, k>
67  {
68  typedef const Tensor4_times_Tensor1_3<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
69  i, j, k, l>
70  TensorExpr;
72  Dim2, i, j, k>(TensorExpr(a, b));
73  }
74 
75  /* A(i,j,k,l)*B(k) -> Tensor3 */
76 
77  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
78  int Dim3, char i, char j, char k, char l>
80  {
83 
84  template <int Current_Dim>
85  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
86  const Number<Current_Dim> &) const
87  {
88  return iterA(N1, N2, Current_Dim - 1, N3) * iterB(Current_Dim - 1)
89  + eval(N1, N2, N3, Number<Current_Dim - 1>());
90  }
91  typename promote<T, U>::V
92  eval(const int N1, const int N2, const int N3, const Number<1> &) const
93  {
94  return iterA(N1, N2, 0, N3) * iterB(0);
95  }
96 
97  public:
98  typename promote<T, U>::V
99  operator()(const int N1, const int N2, const int N3) const
100  {
101  return eval(N1, N2, N3, Number<Dim2>());
102  }
103 
107  : iterA(a), iterB(b)
108  {}
109  };
110 
111  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
112  int Dim3, char i, char j, char k, char l>
113  inline Tensor3_Expr<const Tensor4_times_Tensor1_2<A, B, T, U, Dim0, Dim1,
114  Dim2, Dim3, i, j, k, l>,
115  typename promote<T, U>::V, Dim0, Dim1, Dim3, i, j, l>
118  {
119  typedef const Tensor4_times_Tensor1_2<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
120  i, j, k, l>
121  TensorExpr;
123  Dim3, i, j, l>(TensorExpr(a, b));
124  }
125 
126  /* B(k)*A(i,j,k,l) -> Tensor3 */
127 
128  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
129  int Dim3, char i, char j, char k, char l>
130  inline Tensor3_Expr<const Tensor4_times_Tensor1_2<A, B, T, U, Dim0, Dim1,
131  Dim2, Dim3, i, j, k, l>,
132  typename promote<T, U>::V, Dim0, Dim1, Dim3, i, j, l>
135  {
136  typedef const Tensor4_times_Tensor1_2<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
137  i, j, k, l>
138  TensorExpr;
140  Dim3, i, j, l>(TensorExpr(a, b));
141  }
142 
143  /* A(i,j,k,l)*B(j) -> Tensor3 */
144 
145  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
146  int Dim3, char i, char j, char k, char l>
148  {
151 
152  template <int Current_Dim>
153  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
154  const Number<Current_Dim> &) const
155  {
156  return iterA(N1, Current_Dim - 1, N2, N3) * iterB(Current_Dim - 1)
157  + eval(N1, N2, N3, Number<Current_Dim - 1>());
158  }
159  typename promote<T, U>::V
160  eval(const int N1, const int N2, const int N3, const Number<1> &) const
161  {
162  return iterA(N1, 0, N2, N3) * iterB(0);
163  }
164 
165  public:
166  typename promote<T, U>::V
167  operator()(const int N1, const int N2, const int N3) const
168  {
169  return eval(N1, N2, N3, Number<Dim1>());
170  }
171 
175  : iterA(a), iterB(b)
176  {}
177  };
178 
179  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
180  int Dim3, char i, char j, char k, char l>
181  inline Tensor3_Expr<const Tensor4_times_Tensor1_1<A, B, T, U, Dim0, Dim2,
182  Dim2, Dim3, i, j, k, l>,
183  typename promote<T, U>::V, Dim0, Dim1, Dim3, i, k, l>
186  {
187  typedef const Tensor4_times_Tensor1_1<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
188  i, j, k, l>
189  TensorExpr;
191  Dim3, i, k, l>(TensorExpr(a, b));
192  }
193 
194  /* B(j)*A(i,j,k,l)-> Tensor3 */
195 
196  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
197  int Dim3, char i, char j, char k, char l>
198  inline Tensor3_Expr<const Tensor4_times_Tensor1_1<A, B, T, U, Dim0, Dim1,
199  Dim2, Dim3, i, j, k, l>,
200  typename promote<T, U>::V, Dim0, Dim2, Dim3, i, k, l>
203  {
204  typedef const Tensor4_times_Tensor1_1<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
205  i, j, k, l>
206  TensorExpr;
208  Dim3, i, k, l>(TensorExpr(a, b));
209  }
210 
211  /* A(i,j,k,l)*B(i) -> Tensor3 */
212 
213  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
214  int Dim3, char i, char j, char k, char l>
216  {
219 
220  template <int Current_Dim>
221  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
222  const Number<Current_Dim> &) const
223  {
224  return iterA(Current_Dim - 1, N1, N2, N3) * iterB(Current_Dim - 1)
225  + eval(N1, N2, N3, Number<Current_Dim - 1>());
226  }
227  typename promote<T, U>::V
228  eval(const int N1, const int N2, const int N3, const Number<1> &) const
229  {
230  return iterA(0, N1, N2, N3) * iterB(0);
231  }
232 
233  public:
234  typename promote<T, U>::V
235  operator()(const int N1, const int N2, const int N3) const
236  {
237  return eval(N1, N2, N3, Number<Dim0>());
238  }
239 
243  : iterA(a), iterB(b)
244  {}
245  };
246 
247  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
248  int Dim3, char i, char j, char k, char l>
249  inline Tensor3_Expr<const Tensor4_times_Tensor1_0<A, B, T, U, Dim0, Dim1,
250  Dim2, Dim3, i, j, k, l>,
251  typename promote<T, U>::V, Dim1, Dim2, Dim3, j, k, l>
254  {
255  typedef const Tensor4_times_Tensor1_0<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
256  i, j, k, l>
257  TensorExpr;
259  Dim3, j, k, l>(TensorExpr(a, b));
260  }
261 
262  /* B(i)*A(i,j,k,l)-> Tensor3 */
263 
264  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
265  int Dim3, char i, char j, char k, char l>
266  inline Tensor3_Expr<const Tensor4_times_Tensor1_0<A, B, T, U, Dim0, Dim1,
267  Dim2, Dim3, i, j, k, l>,
268  typename promote<T, U>::V, Dim1, Dim2, Dim3, j, k, l>
271  {
272  typedef const Tensor4_times_Tensor1_0<A, B, T, U, Dim0, Dim1, Dim2, Dim3,
273  i, j, k, l>
274  TensorExpr;
276  Dim3, j, k, l>(TensorExpr(a, b));
277  }
278 }
FTensor::Tensor4_times_Tensor1_3::iterB
const Tensor1_Expr< B, U, Dim3, l > iterB
Definition: Tensor4_times_Tensor1.hpp:14
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::Tensor4_times_Tensor1_2::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim > &) const
Definition: Tensor4_times_Tensor1.hpp:85
FTensor::Tensor4_times_Tensor1_0
Definition: Tensor4_times_Tensor1.hpp:215
FTensor::Tensor4_times_Tensor1_0::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &) const
Definition: Tensor4_times_Tensor1.hpp:228
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor4_times_Tensor1_1::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim > &) const
Definition: Tensor4_times_Tensor1.hpp:153
FTensor::Tensor4_times_Tensor1_2::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor1.hpp:81
FTensor::Tensor4_Expr
Definition: Tensor4_Expr.hpp:25
FTensor::Tensor4_times_Tensor1_1::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor1.hpp:149
FTensor::Number
Definition: Number.hpp:11
FTensor::Tensor1_Expr< B, U, Dim3, l >
FTensor::Tensor4_times_Tensor1_3::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Tensor1.hpp:31
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor4_times_Tensor1_3::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor1.hpp:13
FTensor::Tensor4_times_Tensor1_1::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Tensor1.hpp:167
FTensor::Tensor4_times_Tensor1_1::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &) const
Definition: Tensor4_times_Tensor1.hpp:160
FTensor::Tensor4_times_Tensor1_3::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim > &) const
Definition: Tensor4_times_Tensor1.hpp:17
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_times_Tensor1_0::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim > &) const
Definition: Tensor4_times_Tensor1.hpp:221
FTensor::Tensor4_times_Tensor1_2::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Tensor1.hpp:99
FTensor::Tensor4_times_Tensor1_3
Definition: Tensor4_times_Tensor1.hpp:11
FTensor::Tensor4_times_Tensor1_2::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &) const
Definition: Tensor4_times_Tensor1.hpp:92
FTensor::Tensor3_Expr
Definition: Tensor3_Expr.hpp:24
FTensor::Tensor4_times_Tensor1_1::Tensor4_times_Tensor1_1
Tensor4_times_Tensor1_1(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor1_Expr< B, U, Dim1, j > &b)
Definition: Tensor4_times_Tensor1.hpp:172
FTensor::Tensor4_times_Tensor1_0::iterB
const Tensor1_Expr< B, U, Dim0, i > iterB
Definition: Tensor4_times_Tensor1.hpp:218
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor4_times_Tensor1_1::iterB
const Tensor1_Expr< B, U, Dim1, j > iterB
Definition: Tensor4_times_Tensor1.hpp:150
FTensor::Tensor4_times_Tensor1_3::Tensor4_times_Tensor1_3
Tensor4_times_Tensor1_3(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor1_Expr< B, U, Dim3, l > &b)
Definition: Tensor4_times_Tensor1.hpp:36
FTensor::Tensor4_times_Tensor1_2
Definition: Tensor4_times_Tensor1.hpp:79
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor4_times_Tensor1_0::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor1.hpp:217
FTensor::Tensor4_times_Tensor1_3::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &) const
Definition: Tensor4_times_Tensor1.hpp:24
FTensor::Tensor4_times_Tensor1_2::Tensor4_times_Tensor1_2
Tensor4_times_Tensor1_2(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor1_Expr< B, U, Dim2, k > &b)
Definition: Tensor4_times_Tensor1.hpp:104
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Tensor4_times_Tensor1_0::Tensor4_times_Tensor1_0
Tensor4_times_Tensor1_0(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor1_Expr< B, U, Dim0, i > &b)
Definition: Tensor4_times_Tensor1.hpp:240
FTensor::Tensor4_times_Tensor1_0::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Tensor1.hpp:235
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
FTensor::Tensor4_times_Tensor1_1
Definition: Tensor4_times_Tensor1.hpp:147
FTensor::Tensor4_times_Tensor1_2::iterB
const Tensor1_Expr< B, U, Dim2, k > iterB
Definition: Tensor4_times_Tensor1.hpp:82