v0.14.0
Tensor4_times_Dg_double.hpp
Go to the documentation of this file.
1 /* This file has all of the declarations for expressions like
2  Tensor4*Dg and Tensor3*Dg, yielding a
3  Tensor3. */
4 
5 #pragma once
6 
7 namespace FTensor {
8 /* A(i,j,k,l)*B(k,l,m) */
9 
10 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
11  int Dim3, int Dim4, char i, char j, char k, char l, char m>
15 
16  template <int Current_Dim0, int Current_Dim1>
17  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
18  const Number<Current_Dim0> &,
19  const Number<Current_Dim1> &) const {
20  return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
21  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3) +
23  }
24  template <int Current_Dim1>
25  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
26  const Number<1> &,
27  const Number<Current_Dim1> &) const {
28  return iterA(N1, N2, 0, Current_Dim1 - 1) * iterB(0, Current_Dim1 - 1, N3) +
29  eval(N1, N2, N3, Number<Dim2>(), Number<Current_Dim1 - 1>());
30  }
31  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
32  const Number<1> &, const Number<1> &) const {
33  return iterA(N1, N2, 0, 0) * iterB(0, 0, N3);
34  }
35 
36 public:
37  typename promote<T, U>::V operator()(const int N1, const int N2,
38  const int N3) const {
39  return eval(N1, N2, N3, Number<Dim2>(), Number<Dim3>());
40  }
41 
45  : iterA(a), iterB(b) {
46  static_assert(Dim2 == Dim3, "Dim2 and Dim3 should be equal");
47  }
48 };
49 
50 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
51  int Dim3, int Dim4, char i, char j, char k, char l, char m>
52 inline Tensor3_Expr<const Tensor4_times_Dg_23<A, B, T, U, Dim0, Dim1, Dim2,
53  Dim3, Dim4, i, j, k, l, m>,
54  typename promote<T, U>::V, Dim0, Dim1, Dim4, i, j, m>
57  typedef const Tensor4_times_Dg_23<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, i,
58  j, k, l, m>
59  TensorExpr;
61  i, j, m>(TensorExpr(a, b));
62 }
63 
64 /* B(k,l,m) * A(i,j,k,l) */
65 
66 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
67  int Dim3, int Dim4, char i, char j, char k, char l, char m>
68 inline Tensor3_Expr<const Tensor4_times_Dg_23<A, B, T, U, Dim0, Dim1, Dim2,
69  Dim3, Dim4, i, j, k, l, m>,
70  typename promote<T, U>::V, Dim0, Dim1, Dim4, i, j, m>
73  typedef const Tensor4_times_Dg_23<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, i,
74  j, k, l, m>
75  TensorExpr;
77  i, j, m>(TensorExpr(a, b));
78 }
79 
80 /* A(i,j,k,l)*B(i,j,m) */
81 
82 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
83  int Dim3, int Dim4, char i, char j, char k, char l, char m>
87 
88  template <int Current_Dim0, int Current_Dim1>
89  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
90  const Number<Current_Dim0> &,
91  const Number<Current_Dim1> &) const {
92  return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
93  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3) +
95  }
96  template <int Current_Dim1>
97  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
98  const Number<1> &,
99  const Number<Current_Dim1> &) const {
100  return iterA(0, Current_Dim1 - 1, N1, N2) * iterB(0, Current_Dim1 - 1, N3) +
101  eval(N1, N2, N3, Number<Dim0>(), Number<Current_Dim1 - 1>());
102  }
103  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
104  const Number<1> &, const Number<1> &) const {
105  return iterA(0, 0, N1, N2) * iterB(0, 0, N3);
106  }
107 
108 public:
109  typename promote<T, U>::V operator()(const int N1, const int N2,
110  const int N3) const {
111  return eval(N1, N2, N3, Number<Dim0>(), Number<Dim1>());
112  }
113 
117  : iterA(a), iterB(b) {
118  static_assert(Dim0 == Dim1, "Dim0 and Dim1 should be equal");
119  }
120 };
121 
122 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
123  int Dim3, int Dim4, char i, char j, char k, char l, char m>
124 inline Tensor3_Expr<const Tensor4_times_Dg_01<A, B, T, U, Dim0, Dim1, Dim2,
125  Dim3, Dim4, i, j, k, l, m>,
126  typename promote<T, U>::V, Dim2, Dim3, Dim4, k, l, m>
129  typedef const Tensor4_times_Dg_01<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, i,
130  j, k, l, m>
131  TensorExpr;
133  k, l, m>(TensorExpr(a, b));
134 }
135 
136 /* B(i,j,m)*A(i,j,k,l) */
137 
138 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
139  int Dim3, int Dim4, char i, char j, char k, char l, char m>
140 inline Tensor3_Expr<const Tensor4_times_Dg_01<A, B, T, U, Dim0, Dim1, Dim2,
141  Dim3, Dim4, i, j, k, l, m>,
142  typename promote<T, U>::V, Dim2, Dim3, Dim4, k, l, m>
145  typedef const Tensor4_times_Dg_01<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, i,
146  j, k, l, m>
147  TensorExpr;
149  k, l, m>(TensorExpr(a, b));
150 }
151 
152 } // namespace FTensor
FTensor::Tensor4_times_Dg_23::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Dg_double.hpp:37
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_Dg_23::iterB
const Dg_Expr< B, U, Dim2, Dim4, k, l, m > iterB
Definition: Tensor4_times_Dg_double.hpp:14
FTensor::Tensor4_times_Dg_01::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Dg_double.hpp:97
FTensor::Tensor4_times_Dg_23::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Dg_double.hpp:25
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor4_times_Dg_01::Tensor4_times_Dg_01
Tensor4_times_Dg_01(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Dg_Expr< B, U, Dim0, Dim4, i, j, m > &b)
Definition: Tensor4_times_Dg_double.hpp:114
FTensor::Tensor4_times_Dg_23::Tensor4_times_Dg_23
Tensor4_times_Dg_23(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Dg_Expr< B, U, Dim2, Dim4, k, l, m > &b)
Definition: Tensor4_times_Dg_double.hpp:42
FTensor::Tensor4_times_Dg_23::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Dg_double.hpp:13
FTensor::Tensor4_times_Dg_01
Definition: Tensor4_times_Dg_double.hpp:84
FTensor::Tensor4_Expr
Definition: Tensor4_Expr.hpp:25
FTensor::Number
Definition: Number.hpp:11
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_times_Dg_23
Definition: Tensor4_times_Dg_double.hpp:12
FTensor::Tensor3_Expr
Definition: Tensor3_Expr.hpp:24
FTensor::Tensor4_times_Dg_01::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor4_times_Dg_double.hpp:109
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor4_times_Dg_01::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Dg_double.hpp:89
FTensor::Tensor4_times_Dg_23::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Dg_double.hpp:17
FTensor::Tensor4_times_Dg_01::iterB
const Dg_Expr< B, U, Dim0, Dim4, i, j, m > iterB
Definition: Tensor4_times_Dg_double.hpp:86
FTensor::Tensor4_times_Dg_01::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &, const Number< 1 > &) const
Definition: Tensor4_times_Dg_double.hpp:103
FTensor::Tensor4_times_Dg_23::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const Number< 1 > &, const Number< 1 > &) const
Definition: Tensor4_times_Dg_double.hpp:31
FTensor::Dg_Expr< B, U, Dim2, Dim4, k, l, m >
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
FTensor::Tensor4_times_Dg_01::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Dg_double.hpp:85
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21