v0.8.23
Tensor3_or_Tensor3.hpp
Go to the documentation of this file.
1 /* Adds a Tensor3 to a Tensor3, yielding a Dg. */
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 Dim0_1, int Dim1_1, int Dim2_1, char i0, char j0,
10  char k0, char i1, char j1, char k1>
12  {};
13 
14  /* A(i,j,k)+B(i,k,j)->Dg */
15 
16  template <class A, class B, class T, class U, int Dim0, int Dim12, char i,
17  char j, char k>
18  class Tensor3_or_Tensor3<A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12,
19  i, j, k, i, k, j>
20  {
23 
24  public:
25  typename promote<T, U>::V
26  operator()(const int N1, const int N2, const int N3) const
27  {
28  return iterA(N3, N1, N2) + iterB(N3, N2, N1);
29  }
30 
34  : iterA(a), iterB(b)
35  {}
36  };
37 
38  /* A(i,j,k)+B(k,j,i)->Dg */
39 
40  template <class A, class B, class T, class U, int Dim02, int Dim1, char i,
41  char j, char k>
42  class Tensor3_or_Tensor3<A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02,
43  i, j, k, k, j, i>
44  {
47 
48  public:
49  typename promote<T, U>::V
50  operator()(const int N1, const int N2, const int N3) const
51  {
52  return iterA(N1, N3, N2) + iterB(N2, N3, N1);
53  }
54 
58  : iterA(a), iterB(b)
59  {}
60  };
61 
62  /* A(i,j,k)+B(j,i,k)->Dg */
63 
64  template <class A, class B, class T, class U, int Dim02, int Dim1, char i,
65  char j, char k>
66  class Tensor3_or_Tensor3<A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02,
67  i, j, k, j, i, k>
68  {
71 
72  public:
73  typename promote<T, U>::V
74  operator()(const int N1, const int N2, const int N3) const
75  {
76  return iterA(N1, N2, N3) + iterB(N2, N1, N3);
77  }
78 
82  : iterA(a), iterB(b)
83  {}
84  };
85 
86  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
87  int Dim2_0, int Dim0_1, int Dim1_1, int Dim2_1, char i0, char j0,
88  char k0, char i1, char j1, char k1>
89  auto
92  {
93  using TensorExpr =
94  Tensor3_or_Tensor3<A, B, T, U, Dim0_0, Dim1_0, Dim2_0, Dim0_1, Dim1_1,
95  Dim2_1, i0, j0, k0, i1, j1, k1>;
96  static_assert(
97  !std::is_empty<TensorExpr>::value,
98  "Indexes or Dimensions are not compatible with the || operator");
99 
100  // Definition of Helper constexpr variables
101  constexpr char i = (k0 == i1 || k0 == j1) ? ((i0 == i1) ? j0 : i0) : i0;
102  constexpr char j = (k0 == i1 || k0 == j1) ? k0 : j0;
103  constexpr char k = (k0 == i1 || k0 == j1) ? ((i0 == i1) ? i0 : j0) : k0;
104 
105  return Dg_Expr<TensorExpr, typename promote<T, U>::V, Dim0_0, Dim1_0, i,
106  j, k>(TensorExpr(a, b));
107  }
108 }
Fully Antisymmetric Levi-Civita Tensor.
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > &a, const Tensor3_Expr< B, U, Dim02, Dim1, Dim02, j, i, k > &b)
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim0, Dim12, Dim12, i, j, k > &a, const Tensor3_Expr< B, U, Dim0, Dim12, Dim12, i, k, j > &b)
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > &a, const Tensor3_Expr< B, U, Dim02, Dim1, Dim02, k, j, i > &b)
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