v0.14.0
Tensor4_times_Tensor4_double.hpp
Go to the documentation of this file.
1 /**
2  * @file Tensor4_times_Tensor4_double.hpp
3  * @brief Tensor4 times Tensor4 yields Tensor4
4  * @date 2022-10-18
5  *
6  * @copyright Copyright (c) 2022
7  *
8  */
9 
10 #pragma once
11 
12 namespace FTensor {
13 
14 /* Double contraction. */
15 
16 /* A(i,j,k,l)*B(k,l,m,n) */
17 
18 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
19  int Dim3, int Dim4, int Dim5, char i, char j, char k, char l, char m,
20  char n>
24 
25  template <int Current_Dim0, int Current_Dim1>
26  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
27  const int N4, const Number<Current_Dim0> &,
28  const Number<Current_Dim1> &) const {
29  return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
30  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
31  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
33  }
34  template <int Current_Dim1>
35  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
36  const int N4, const Number<1> &,
37  const Number<Current_Dim1> &) const {
38  return iterA(N1, N2, 0, Current_Dim1 - 1) *
39  iterB(0, Current_Dim1 - 1, N3, N4) +
40  eval(N1, N2, N3, N4, Number<Dim2>(), Number<Current_Dim1 - 1>());
41  }
42  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
43  const int N4, const Number<1> &,
44  const Number<1> &) const {
45  return iterA(N1, N2, 0, 0) * iterB(0, 0, N3, N4);
46  }
47 
48 public:
49  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
50  const int N4) const {
51  return eval(N1, N2, N3, N4, Number<Dim2>(), Number<Dim3>());
52  }
53 
57  : iterA(a), iterB(b) {}
58 };
59 
60 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
61  int Dim3, int Dim4, int Dim5, char i, char j, char k, char l, char m,
62  char n>
63 inline auto
66  using TensorExpr =
67  Tensor4_times_Tensor4_2345<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, Dim5,
68  i, j, k, l, m, n>;
70  Dim5, i, j, m, n>(TensorExpr(a, b));
71 }
72 
73 /* A(i,j,k,l)*B(i,j,m,n) */
74 
75 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
76  int Dim3, int Dim4, int Dim5, char i, char j, char k, char l, char m,
77  char n>
81 
82  template <int Current_Dim0, int Current_Dim1>
83  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
84  const int N4, const Number<Current_Dim0> &,
85  const Number<Current_Dim1> &) const {
86  return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
87  iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
88  eval(N1, N2, N3, N4, Number<Current_Dim0 - 1>(),
90  }
91  template <int Current_Dim1>
92  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
93  const int N4, const Number<1> &,
94  const Number<Current_Dim1> &) const {
95  return iterA(0, Current_Dim1 - 1, N1, N2) *
96  iterB(0, Current_Dim1 - 1, N3, N4) +
97  eval(N1, N2, N3, N4, Number<Dim2>(), Number<Current_Dim1 - 1>());
98  }
99  typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
100  const int N4, const Number<1> &,
101  const Number<1> &) const {
102  return iterA(0, 0, N1, N2) * iterB(0, 0, N3, N4);
103  }
104 
105 public:
106  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
107  const int N4) const {
108  return eval(N1, N2, N3, N4, Number<Dim2>(), Number<Dim3>());
109  }
110 
114  : iterA(a), iterB(b) {}
115 };
116 
117 template <class A, class B, class T, class U, int Dim0, int Dim1, int Dim2,
118  int Dim3, int Dim4, int Dim5, char i, char j, char k, char l, char m,
119  char n>
120 inline auto
123  using TensorExpr =
124  Tensor4_times_Tensor4_0145<A, B, T, U, Dim0, Dim1, Dim2, Dim3, Dim4, Dim5,
125  i, j, k, l, m, n>;
127  Dim5, m, n, k, l>(TensorExpr(a, b));
128 }
129 }
FTensor::Tensor4_times_Tensor4_2345::Tensor4_times_Tensor4_2345
Tensor4_times_Tensor4_2345(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor4_Expr< B, U, Dim2, Dim3, Dim4, Dim5, k, l, m, n > &b)
Definition: Tensor4_times_Tensor4_double.hpp:54
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_Tensor4_0145::Tensor4_times_Tensor4_0145
Tensor4_times_Tensor4_0145(const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > &a, const Tensor4_Expr< B, U, Dim0, Dim1, Dim4, Dim5, i, j, m, n > &b)
Definition: Tensor4_times_Tensor4_double.hpp:111
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor4_times_Tensor4_2345::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:42
FTensor::Tensor4_times_Tensor4_2345::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:35
FTensor::Tensor4_times_Tensor4_0145::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:92
FTensor::Tensor4_times_Tensor4_0145::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Tensor4_times_Tensor4_double.hpp:106
FTensor::Tensor4_Expr
Definition: Tensor4_Expr.hpp:25
FTensor::Number
Definition: Number.hpp:11
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor4_times_Tensor4_0145::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor4_double.hpp:79
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_times_Tensor4_0145
Definition: Tensor4_times_Tensor4_double.hpp:78
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor4_times_Tensor4_2345::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:26
convert.n
n
Definition: convert.py:82
FTensor::Tensor4_times_Tensor4_2345
Definition: Tensor4_times_Tensor4_double.hpp:21
FTensor::Tensor4_times_Tensor4_2345::iterB
const Tensor4_Expr< B, U, Dim2, Dim3, Dim4, Dim5, k, l, m, n > iterB
Definition: Tensor4_times_Tensor4_double.hpp:23
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor4_times_Tensor4_0145::iterB
const Tensor4_Expr< B, U, Dim0, Dim1, Dim4, Dim5, i, j, m, n > iterB
Definition: Tensor4_times_Tensor4_double.hpp:80
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
FTensor::Tensor4_times_Tensor4_0145::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:83
FTensor::Tensor4_times_Tensor4_2345::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Tensor4_times_Tensor4_double.hpp:49
FTensor::Tensor4_times_Tensor4_2345::iterA
const Tensor4_Expr< A, T, Dim0, Dim1, Dim2, Dim3, i, j, k, l > iterA
Definition: Tensor4_times_Tensor4_double.hpp:22
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Tensor4_times_Tensor4_0145::eval
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
Definition: Tensor4_times_Tensor4_double.hpp:99
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21