v0.14.0
Tensor2_plus_Tensor2.hpp
Go to the documentation of this file.
1 /* Adds a Tensor2 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 Dim0_0, int Dim1_0,
9  int Dim0_1, int Dim1_1, char i0, char j0, char i1, char j1>
11  {};
12 
13  /* A(i,j)+B(i,j) */
14 
15  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
16  char j>
17  class Tensor2_plus_Tensor2<A, B, T, U, Dim0, Dim1, Dim0, Dim1, i, j, i, j>
18  {
21 
22  public:
23  typename promote<T, U>::V operator()(const int N1, const int N2) const
24  {
25  return iterA(N1, N2) + iterB(N1, N2);
26  }
27 
30  : iterA(a), iterB(b)
31  {}
32  };
33 
34  /* A(i,j)+B(j,i) */
35 
36  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
37  char j>
38  class Tensor2_plus_Tensor2<A, B, T, U, Dim0, Dim1, Dim1, Dim0, i, j, j, i>
39  {
42 
43  public:
44  typename promote<T, U>::V operator()(const int N1, const int N2) const
45  {
46  return iterA(N1, N2) + iterB(N2, N1);
47  }
48 
51  : iterA(a), iterB(b)
52  {}
53  };
54 
55  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
56  int Dim0_1, int Dim1_1, char i0, char j0, char i1, char j1>
57  Tensor2_Expr<Tensor2_plus_Tensor2<A, B, T, U, Dim0_0, Dim1_0, Dim0_1, Dim1_1,
58  i0, j0, i1, j1>,
59  typename promote<T, U>::V, Dim0_0, Dim1_0, i0, j0>
62  {
63  using TensorExpr = Tensor2_plus_Tensor2<A, B, T, U, Dim0_0, Dim1_0, Dim0_1,
64  Dim1_1, i0, j0, i1, j1>;
65  static_assert(
66  !std::is_empty<TensorExpr>::value,
67  "Indexes or Dimensions are not compatible with the + operator");
69  i0, j0>(TensorExpr(a, b));
70  }
71 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim0, Dim1, i, j, i, j >::iterA
const Tensor2_Expr< A, T, Dim0, Dim1, i, j > iterA
Definition: Tensor2_plus_Tensor2.hpp:19
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_plus_Tensor2
Definition: Tensor2_plus_Tensor2.hpp:10
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim1, Dim0, i, j, j, i >::iterB
const Tensor2_Expr< B, U, Dim1, Dim0, j, i > iterB
Definition: Tensor2_plus_Tensor2.hpp:41
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim0, Dim1, i, j, i, j >::iterB
const Tensor2_Expr< B, U, Dim0, Dim1, i, j > iterB
Definition: Tensor2_plus_Tensor2.hpp:20
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim1, Dim0, i, j, j, i >::iterA
const Tensor2_Expr< A, T, Dim0, Dim1, i, j > iterA
Definition: Tensor2_plus_Tensor2.hpp:40
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim1, Dim0, i, j, j, i >::Tensor2_plus_Tensor2
Tensor2_plus_Tensor2(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a, const Tensor2_Expr< B, U, Dim1, Dim0, j, i > &b)
Definition: Tensor2_plus_Tensor2.hpp:49
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim0, Dim1, i, j, i, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_plus_Tensor2.hpp:23
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::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim0, Dim1, i, j, i, j >::Tensor2_plus_Tensor2
Tensor2_plus_Tensor2(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a, const Tensor2_Expr< B, U, Dim0, Dim1, i, j > &b)
Definition: Tensor2_plus_Tensor2.hpp:28
FTensor::Tensor2_plus_Tensor2< A, B, T, U, Dim0, Dim1, Dim1, Dim0, i, j, j, i >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_plus_Tensor2.hpp:44
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197