v0.14.0
Ddg_plus_Ddg.hpp
Go to the documentation of this file.
1 /* Adds Ddg+Ddg -> Ddg */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* Base Template */
8  template <class A, class B, class T, class U, int Dim01_0, int Dim23_0,
9  int Dim01_1, int Dim23_1, char i0, char j0, char k0, char l0,
10  char i1, char j1, char k1, char l1>
12  {};
13 
14  /* A(i,j,k,l)+B(i,j,k,l) -> 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 Ddg_plus_Ddg<A, B, T, U, Dim01, Dim23, Dim01, Dim23, i, j, k, l, i, j,
19  k, l>
20  {
23 
24  public:
25  typename promote<T, U>::V
26  operator()(const int N1, const int N2, const int N3, const int N4) const
27  {
28  return iterA(N1, N2, N3, N4) + iterB(N1, N2, N3, N4);
29  }
30 
33  : iterA(a), iterB(b)
34  {}
35  };
36 
37  /* A(i,j,k,l)+B(k,l,i,j) -> Ddg */
38  // TODO: Add rest of combinations (k,l,j,i), (l,k,i,j), (l,k,j,i)
39  template <class A, class B, class T, class U, int Dim01, int Dim23, char i,
40  char j, char k, char l>
41  class Ddg_plus_Ddg<A, B, T, U, Dim01, Dim23, Dim23, Dim01, i, j, k, l, k, l,
42  i, j>
43  {
46 
47  public:
48  typename promote<T, U>::V
49  operator()(const int N1, const int N2, const int N3, const int N4) const
50  {
51  return iterA(N1, N2, N3, N4) + iterB(N3, N4, N1, N2);
52  }
53 
56  : iterA(a), iterB(b)
57  {}
58  };
59 
60  template <class A, class B, class T, class U, int Dim01_0, int Dim23_0,
61  int Dim01_1, int Dim23_1, char i0, char j0, char k0, char l0,
62  char i1, char j1, char k1, char l1>
63  Ddg_Expr<Ddg_plus_Ddg<A, B, T, U, Dim01_0, Dim23_0, Dim01_1, Dim23_1, i0, j0,
64  k0, l0, i1, j1, k1, l1>,
65  typename promote<T, U>::V, Dim01_0, Dim23_0, i0, j0, k0, l0>
68  {
69  using TensorExpr = Ddg_plus_Ddg<A, B, T, U, Dim01_0, Dim23_0, Dim01_1,
70  Dim23_1, i0, j0, k0, l0, i1, j1, k1, l1>;
71  static_assert(
72  !std::is_empty<TensorExpr>::value,
73  "Indexes or Dimensions are not compatible with the + operator");
74  return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01_0, Dim23_0,
75  i0, j0, k0, l0>(TensorExpr(a, b));
76  }
77 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim23, Dim01, i, j, k, l, k, l, i, j >::iterA
Ddg_Expr< A, T, Dim01, Dim23, i, j, k, l > iterA
Definition: Ddg_plus_Ddg.hpp:44
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim23, Dim01, i, j, k, l, k, l, i, j >::Ddg_plus_Ddg
Ddg_plus_Ddg(const Ddg_Expr< A, T, Dim01, Dim23, i, j, k, l > &a, const Ddg_Expr< B, U, Dim23, Dim01, k, l, i, j > &b)
Definition: Ddg_plus_Ddg.hpp:54
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim01, Dim23, i, j, k, l, i, j, k, l >::iterA
Ddg_Expr< A, T, Dim01, Dim23, i, j, k, l > iterA
Definition: Ddg_plus_Ddg.hpp:21
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim23, Dim01, i, j, k, l, k, l, i, j >::iterB
Ddg_Expr< B, U, Dim23, Dim01, k, l, i, j > iterB
Definition: Ddg_plus_Ddg.hpp:45
FTensor::Ddg_Expr
Definition: Ddg_Expr.hpp:28
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim01, Dim23, i, j, k, l, i, j, k, l >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_plus_Ddg.hpp:26
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim01, Dim23, i, j, k, l, i, j, k, l >::iterB
Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > iterB
Definition: Ddg_plus_Ddg.hpp:22
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim23, Dim01, i, j, k, l, k, l, i, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Ddg_plus_Ddg.hpp:49
FTensor::operator+
Ddg_Expr< Ddg_plus_Ddg< A, B, T, U, Dim01_0, Dim23_0, Dim01_1, Dim23_1, i0, j0, k0, l0, i1, j1, k1, l1 >, typename promote< T, U >::V, Dim01_0, Dim23_0, i0, j0, k0, l0 > operator+(const Ddg_Expr< A, T, Dim01_0, Dim23_0, i0, j0, k0, l0 > &a, const Ddg_Expr< B, U, Dim01_1, Dim23_1, i1, j1, k1, l1 > &b)
Definition: Ddg_plus_Ddg.hpp:66
FTensor::Ddg_plus_Ddg
Definition: Ddg_plus_Ddg.hpp:11
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Ddg_plus_Ddg< A, B, T, U, Dim01, Dim23, Dim01, Dim23, i, j, k, l, i, j, k, l >::Ddg_plus_Ddg
Ddg_plus_Ddg(const Ddg_Expr< A, T, Dim01, Dim23, i, j, k, l > &a, const Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > &b)
Definition: Ddg_plus_Ddg.hpp:31
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21