v0.14.0
Tensor2_symmetric_plus_Tensor2.hpp
Go to the documentation of this file.
1 /* Adds a Tensor2_symmetric to a Tensor2, yielding a Tensor2. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* Base Template */
8  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
9  int Dim1_1, char i0, char j0, char i1, char j1>
11  {};
12 
13  /* A(i,j)+B(i,j), A is symmetric, B is not. */
14 
15  template <class A, class B, class T, class U, int Dim, char i, char j>
16  class Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, i, j>
17  {
20 
21  public:
22  typename promote<T, U>::V operator()(const int N1, const int N2) const
23  {
24  return iterA(N1, N2) + iterB(N1, N2);
25  }
26 
30  : iterA(a), iterB(b)
31  {}
32  };
33 
34  /* A(i,j)+B(j,i), A is symmetric, B is not. */
35 
36  template <class A, class B, class T, class U, int Dim, char i, char j>
37  class Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, j, i>
38  {
41 
42  public:
43  typename promote<T, U>::V operator()(const int N1, const int N2) const
44  {
45  return iterA(N1, N2) + iterB(N2, N1);
46  }
47 
51  : iterA(a), iterB(b)
52  {}
53  };
54 
55  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
56  int Dim1_1, char i0, char j0, char i1, char j1>
57  Tensor2_Expr<Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim_0, Dim0_1,
58  Dim1_1, i0, j0, i1, j1>,
59  typename promote<T, U>::V, Dim_0, Dim_0, i0, j0>
62  {
63  using TensorExpr
64  = Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
65  j0, i1, j1>;
66  static_assert(
67  !std::is_empty<TensorExpr>::value,
68  "Indexes or Dimensions are not compatible with the + operator");
70  i0, j0>(TensorExpr(a, b));
71  }
72 
73  // TODO We are not respecting operation order here. I suggest to use the same
74  // approach as in Tensor2_symmetric minus Tensor2
75  /* B(i,j)+A(i,j), A is symmetric, B is not. */
76  /* B(i,j)+A(j,i), A is symmetric, B is not. */
77 
78  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
79  int Dim1_1, char i0, char j0, char i1, char j1>
80  Tensor2_Expr<Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim_0, Dim0_1,
81  Dim1_1, i0, j0, i1, j1>,
82  typename promote<T, U>::V, Dim_0, Dim_0, i0, j0>
85  {
86  using TensorExpr
87  = Tensor2_symmetric_plus_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
88  j0, i1, j1>;
89  static_assert(
90  !std::is_empty<TensorExpr>::value,
91  "Indexes or Dimensions are not compatible with the + operator");
93  i0, j0>(TensorExpr(a, b));
94  }
95 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, i, j >::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_plus_Tensor2.hpp:18
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, i >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_plus_Tensor2.hpp:43
FTensor::Tensor2_Expr< B, U, Dim, Dim, i, j >
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, i, j >::iterB
Tensor2_Expr< B, U, Dim, Dim, i, j > iterB
Definition: Tensor2_symmetric_plus_Tensor2.hpp:19
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, i >::iterA
Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_plus_Tensor2.hpp:39
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, i >::iterB
Tensor2_Expr< B, U, Dim, Dim, j, i > iterB
Definition: Tensor2_symmetric_plus_Tensor2.hpp:40
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_symmetric_plus_Tensor2
Definition: Tensor2_symmetric_plus_Tensor2.hpp:10
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, i, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_plus_Tensor2.hpp:22
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, i >::Tensor2_symmetric_plus_Tensor2
Tensor2_symmetric_plus_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, j, i > &b)
Definition: Tensor2_symmetric_plus_Tensor2.hpp:48
FTensor::Tensor2_symmetric_plus_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, i, j >::Tensor2_symmetric_plus_Tensor2
Tensor2_symmetric_plus_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, i, j > &b)
Definition: Tensor2_symmetric_plus_Tensor2.hpp:27
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
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197