v0.14.0
Tensor4_or_Tensor4.hpp
Go to the documentation of this file.
1 /* Adds a Tensor4 to a Tensor4, yielding a Ddg. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* Base Template */
8 template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
9  int Dim2_0, int Dim3_0, int Dim0_1, int Dim1_1, int Dim2_1,
10  int Dim3_1, char i0, char j0, char k0, char l0, char i1, char j1,
11  char k1, char l1>
13 
14 /* A(i,j,k,l)+B(j,i,l,k)->Ddg */
15 
16 template <class A, class B, class T, class U, int Dim01, int Dim23, char i,
17  char j, char k, char l>
18 class Tensor4_or_Tensor4<A, B, T, U, Dim01, Dim01, Dim23, Dim23, Dim01, Dim01,
19  Dim23, Dim23, i, j, k, l, j, i, l, k> {
22 
23 public:
24  typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
25  const int N4) const {
26  return iterA(N1, N2, N3, N4) + iterB(N2, N1, N4, N3);
27  }
28 
32  : iterA(a), iterB(b) {}
33  };
34 
35  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
36  int Dim2_0, int Dim3_0, int Dim0_1, int Dim1_1, int Dim2_1,
37  int Dim3_1, char i0, char j0, char k0, char l0, char i1, char j1,
38  char k1, char l1>
39  auto operator||(const Tensor4_Expr<A, T, Dim0_0, Dim1_0, Dim2_0, Dim3_0, i0,
40  j0, k0, l0> &a,
41  const Tensor4_Expr<B, U, Dim0_1, Dim1_1, Dim2_1, Dim3_1, i1,
42  j1, k1, l1> &b) {
43  using TensorExpr =
44  Tensor4_or_Tensor4<A, B, T, U, Dim0_0, Dim1_0, Dim2_0, Dim3_0, Dim0_1,
45  Dim1_1, Dim2_1, Dim3_1, i0, j0, k0, l0, i1, j1, k1,
46  l1>;
47  static_assert(
48  !std::is_empty<TensorExpr>::value,
49  "Indexes or Dimensions are not compatible with the || operator");
50 
51  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim0_0, Dim2_1, i0,
52  j0, k0, l0>(TensorExpr(a, b));
53  }
54 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Ddg_Expr
Definition: Ddg_Expr.hpp:28
FTensor::operator||
Ddg_Expr< Ddg_or_Ddg< A, B, T, U, Dim, i, j, k, l >, typename promote< T, U >::V, Dim, Dim, i, k, j, l > operator||(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, l, k, j > &b)
Definition: Ddg_or_Ddg.hpp:33
FTensor::Tensor4_or_Tensor4< A, B, T, U, Dim01, Dim01, Dim23, Dim23, Dim01, Dim01, Dim23, Dim23, i, j, k, l, j, i, l, k >::iterB
Tensor4_Expr< B, U, Dim01, Dim01, Dim23, Dim23, j, i, l, k > iterB
Definition: Tensor4_or_Tensor4.hpp:21
FTensor::Tensor4_Expr< A, T, Dim01, Dim01, Dim23, Dim23, i, j, k, l >
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor4_or_Tensor4
Definition: Tensor4_or_Tensor4.hpp:12
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor4_or_Tensor4< A, B, T, U, Dim01, Dim01, Dim23, Dim23, Dim01, Dim01, Dim23, Dim23, i, j, k, l, j, i, l, k >::iterA
Tensor4_Expr< A, T, Dim01, Dim01, Dim23, Dim23, i, j, k, l > iterA
Definition: Tensor4_or_Tensor4.hpp:20
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor4_or_Tensor4< A, B, T, U, Dim01, Dim01, Dim23, Dim23, Dim01, Dim01, Dim23, Dim23, i, j, k, l, j, i, l, k >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Tensor4_or_Tensor4.hpp:24
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
FTensor::Tensor4_or_Tensor4< A, B, T, U, Dim01, Dim01, Dim23, Dim23, Dim01, Dim01, Dim23, Dim23, i, j, k, l, j, i, l, k >::Tensor4_or_Tensor4
Tensor4_or_Tensor4(const Tensor4_Expr< A, T, Dim01, Dim01, Dim23, Dim23, i, j, k, l > &a, const Tensor4_Expr< B, U, Dim01, Dim01, Dim23, Dim23, j, i, l, k > &b)
Definition: Tensor4_or_Tensor4.hpp:29