v0.14.0
Tensor3_times_Tensor1.hpp
Go to the documentation of this file.
1 /* Declarations for expressions like Tensor3*Tensor1 -> Tensor2 */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* A(i,j,k)*B(j) -> Tensor2 */
8 
9  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
10  char i, char j, char k>
12  {
15 
16  template <int Current_Dim>
17  typename promote<T, U>::V
18  eval(const int N1, const int N2, const Number<Current_Dim> &) const
19  {
20  return iterA(N1, Current_Dim - 1, N2) * iterB(Current_Dim - 1)
21  + eval(N1, N2, Number<Current_Dim - 1>());
22  }
23  typename promote<T, U>::V
24  eval(const int N1, const int N2, const Number<1> &) const
25  {
26  return iterA(N1, 0, N2) * iterB(0);
27  }
28 
29  public:
33  : iterA(a), iterB(b)
34  {}
35  typename promote<T, U>::V operator()(const int N1, const int N2) const
36  {
37  return eval(N1, N2, Number<Dim1>());
38  }
39  };
40 
41  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
42  char i, char j, char k>
43  Tensor2_Expr<Tensor3_times_Tensor1_1<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
44  typename promote<T, U>::V, Dim0, Dim2, i, k>
47  {
48  using TensorExpr
51  k>(TensorExpr(a, b));
52  }
53 
54  /* B(j)*A(i,j,k) -> Tensor2 */
55 
56  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
57  char i, char j, char k>
58  Tensor2_Expr<Tensor3_times_Tensor1_1<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
59  typename promote<T, U>::V, Dim0, Dim2, i, k>
62  {
63  using TensorExpr
66  k>(TensorExpr(a, b));
67  }
68 
69  /* A(i,j,k)*B(i) -> Tensor2 */
70 
71  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
72  char i, char j, char k>
74  {
77 
78  template <int Current_Dim>
79  typename promote<T, U>::V
80  eval(const int N1, const int N2, const Number<Current_Dim> &) const
81  {
82  return iterA(Current_Dim - 1, N1, N2) * iterB(Current_Dim - 1)
83  + eval(N1, N2, Number<Current_Dim - 1>());
84  }
85  typename promote<T, U>::V
86  eval(const int N1, const int N2, const Number<1> &) const
87  {
88  return iterA(0, N1, N2) * iterB(0);
89  }
90 
91  public:
95  : iterA(a), iterB(b)
96  {}
97  typename promote<T, U>::V operator()(const int N1, const int N2) const
98  {
99  return eval(N1, N2, Number<Dim0>());
100  }
101  };
102 
103  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
104  char i, char j, char k>
105  Tensor2_Expr<Tensor3_times_Tensor1_0<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
106  typename promote<T, U>::V, Dim1, Dim2, j, k>
109  {
110  using TensorExpr
113  k>(TensorExpr(a, b));
114  }
115 
116  /* B(i)*A(i,j,k) -> Tensor2 */
117 
118  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
119  char i, char j, char k>
120  Tensor2_Expr<Tensor3_times_Tensor1_0<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
121  typename promote<T, U>::V, Dim1, Dim2, j, k>
124  {
125  using TensorExpr
128  k>(TensorExpr(a, b));
129  }
130 
131  /* A(i,j,k)*B(k) -> Tensor2 */
132 
133  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
134  char i, char j, char k>
136  {
139 
140  template <int CurrentDim>
141  typename promote<T, U>::V
142  eval(const int N1, const int N2, const Number<CurrentDim> &) const
143  {
144  return iterA(N1, N2, CurrentDim - 1) * iterB(CurrentDim - 1)
145  + eval(N1, N2, Number<CurrentDim - 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, N2, 0) * iterB(0);
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<Dim2>());
162  }
163  };
164 
165  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
166  char i, char j, char k>
167  Tensor2_Expr<Tensor3_times_Tensor1_2<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
168  typename promote<T, U>::V, Dim0, Dim1, i, j>
171  {
172  using TensorExpr
175  j>(TensorExpr(a, b));
176  };
177 
178  /* A(i,j,k)*B(k) -> Tensor2 */
179 
180  template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
181  char i, char j, char k>
182  Tensor2_Expr<Tensor3_times_Tensor1_2<A, B, T, U, Dim0, Dim1, Dim2, i, j, k>,
183  typename promote<T, U>::V, Dim0, Dim1, i, j>
186  {
187  using TensorExpr
190  j>(TensorExpr(a, b));
191  };
192 }
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::Tensor3_times_Tensor1_0
Definition: Tensor3_times_Tensor1.hpp:73
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor3_times_Tensor1_0::iterB
Tensor1_Expr< B, U, Dim0, i > iterB
Definition: Tensor3_times_Tensor1.hpp:76
FTensor::Tensor3_times_Tensor1_2::Tensor3_times_Tensor1_2
Tensor3_times_Tensor1_2(const Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > &a, const Tensor1_Expr< B, U, Dim2, k > &b)
Definition: Tensor3_times_Tensor1.hpp:154
FTensor::Tensor3_times_Tensor1_0::Tensor3_times_Tensor1_0
Tensor3_times_Tensor1_0(const Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > &a, const Tensor1_Expr< B, U, Dim0, i > &b)
Definition: Tensor3_times_Tensor1.hpp:92
FTensor::Tensor3_times_Tensor1_2::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor3_times_Tensor1.hpp:148
FTensor::Number
Definition: Number.hpp:11
FTensor::Tensor3_times_Tensor1_0::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor3_times_Tensor1.hpp:80
FTensor::Tensor1_Expr< B, U, Dim1, j >
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor3_times_Tensor1_1::iterA
Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > iterA
Definition: Tensor3_times_Tensor1.hpp:13
FTensor::Tensor3_times_Tensor1_1::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor3_times_Tensor1.hpp:35
FTensor::Tensor3_times_Tensor1_2::iterA
Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > iterA
Definition: Tensor3_times_Tensor1.hpp:137
FTensor::Tensor3_times_Tensor1_1::iterB
Tensor1_Expr< B, U, Dim1, j > iterB
Definition: Tensor3_times_Tensor1.hpp:14
FTensor::Tensor3_times_Tensor1_2::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< CurrentDim > &) const
Definition: Tensor3_times_Tensor1.hpp:142
FTensor::Tensor3_times_Tensor1_0::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor3_times_Tensor1.hpp:86
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor3_times_Tensor1_2::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor3_times_Tensor1.hpp:159
FTensor::Tensor3_times_Tensor1_2::iterB
Tensor1_Expr< B, U, Dim2, k > iterB
Definition: Tensor3_times_Tensor1.hpp:138
FTensor::Tensor3_Expr
Definition: Tensor3_Expr.hpp:24
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor3_times_Tensor1_2
Definition: Tensor3_times_Tensor1.hpp:135
FTensor::Tensor3_times_Tensor1_1::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor3_times_Tensor1.hpp:24
FTensor::Tensor3_times_Tensor1_1::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor3_times_Tensor1.hpp:18
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor3_times_Tensor1_1
Definition: Tensor3_times_Tensor1.hpp:11
FTensor::Tensor3_times_Tensor1_0::iterA
Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > iterA
Definition: Tensor3_times_Tensor1.hpp:75
FTensor::Tensor3_times_Tensor1_0::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor3_times_Tensor1.hpp:97
FTensor::Tensor3_times_Tensor1_1::Tensor3_times_Tensor1_1
Tensor3_times_Tensor1_1(const Tensor3_Expr< A, T, Dim0, Dim1, Dim2, i, j, k > &a, const Tensor1_Expr< B, U, Dim1, j > &b)
Definition: Tensor3_times_Tensor1.hpp:30
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197