v0.13.2
Searching...
No Matches
Tensor2_symmetric_carat_Tensor2.hpp
Go to the documentation of this file.
1/* Creates a Tensor2_symmetric expression by contracting a
2 Tensor2_symmetric and a Tensor2 together. There are different
3 versions, depending on where the contracting indices are located
4 (i.e. whether it is A(i,j)^B(j,k) or A(i,j)^B(k,j)). The classes
5 are numbered to differentiate between these. Thus, A(i,j)^B(j,k)
6 has 10 appended to the name because I count from 0. */
7
8#pragma once
9
10namespace FTensor
11{
12 /* Base Template */
13 template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
14 int Dim1_1, char i0, char j0, char i1, char j1>
16 {};
17
18 /* A(i,j)*B(j,k) */
19
20 template <class A, class B, class T, class U, int Dim, char i, char j, char k>
21 class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, j, k>
22 {
25
26 template <int Current_Dim>
27 typename promote<T, U>::V
28 eval(const int N1, const int N2, const Number<Current_Dim> &) const
29 {
30 return iterA(N1, Current_Dim - 1) * iterB(Current_Dim - 1, N2)
31 + eval(N1, N2, Number<Current_Dim - 1>());
32 }
33 typename promote<T, U>::V
34 eval(const int N1, const int N2, const Number<1> &) const
35 {
36 return iterA(N1, 0) * iterB(0, N2);
37 }
38
39 public:
43 : iterA(a), iterB(b)
44 {}
45 typename promote<T, U>::V operator()(const int N1, const int N2) const
46 {
47 return eval(N1, N2, Number<Dim>());
48 }
49 };
50
51 /* A(i,j)*B(k,j) */
52
53 template <class A, class B, class T, class U, int Dim, char i, char j, char k>
54 class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, k, j>
55 {
58
59 template <int Current_Dim>
60 typename promote<T, U>::V
61 eval(const int N1, const int N2, const Number<Current_Dim> &) const
62 {
63 return iterA(N1, Current_Dim - 1) * iterB(N2, Current_Dim - 1)
64 + eval(N1, N2, Number<Current_Dim - 1>());
65 }
66 typename promote<T, U>::V
67 eval(const int N1, const int N2, const Number<1> &) const
68 {
69 return iterA(N1, 0) * iterB(N2, 0);
70 }
71
72 public:
76 : iterA(a), iterB(b)
77 {}
78 typename promote<T, U>::V operator()(const int N1, const int N2) const
79 {
80 return eval(N1, N2, Number<Dim>());
81 }
82 };
83
84 /* A(j,i)*B(j,k) */
85
86 template <class A, class B, class T, class U, int Dim, char i, char j, char k>
87 class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, j, i, j, k>
88 {
91
92 template <int Current_Dim>
93 typename promote<T, U>::V
94 eval(const int N1, const int N2, const Number<Current_Dim> &) const
95 {
96 return iterA(Current_Dim - 1, N1) * iterB(Current_Dim - 1, N2)
97 + eval(N1, N2, Number<Current_Dim - 1>());
98 }
99 typename promote<T, U>::V
100 eval(const int N1, const int N2, const Number<1> &) const
101 {
102 return iterA(0, N1) * iterB(0, N2);
103 }
104
105 public:
109 : iterA(a), iterB(b)
110 {}
111 typename promote<T, U>::V operator()(const int N1, const int N2) const
112 {
113 return eval(N1, N2, Number<Dim>());
114 }
115 };
116
117 /* A(j,i)*B(k,j) */
118
119 template <class A, class B, class T, class U, int Dim, char i, char j, char k>
120 class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, j, i, k, j>
121 {
124
125 template <int Current_Dim>
126 typename promote<T, U>::V
127 eval(const int N1, const int N2, const Number<Current_Dim> &) const
128 {
129 return iterA(Current_Dim - 1, N1) * iterB(N2, Current_Dim - 1)
130 + eval(N1, N2, Number<Current_Dim - 1>());
131 }
132 typename promote<T, U>::V
133 eval(const int N1, const int N2, const Number<1> &) const
134 {
135 return iterA(0, N1) * iterB(N2, 0);
136 }
137
138 public:
142 : iterA(a), iterB(b)
143 {}
144 typename promote<T, U>::V operator()(const int N1, const int N2) const
145 {
146 return eval(N1, N2, Number<Dim>());
147 }
148 };
149
150 template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
151 int Dim1_1, char i0, char j0, char i1, char j1>
154 {
155 using TensorExpr
156 = Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
157 j0, i1, j1>;
158 static_assert(
159 !std::is_empty<TensorExpr>::value,
160 "Indexes or Dimensions are not compatible with the ^ operator");
161
162 // Definition of Helper constexpr variables
163 constexpr char i = (i0 == i1 || i0 == j1) ? j0 : i0,
164 j = (i1 == i0 || i1 == j0) ? j1 : i1;
165
167 i, j>(TensorExpr(a, b));
168 }
169
170 /* B(k,j)*A(j,i) */
171
172 template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
173 int Dim1_1, char i0, char j0, char i1, char j1>
176 {
177 using TensorExpr
178 = Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
179 j0, i1, j1>;
180 static_assert(
181 !std::is_empty<TensorExpr>::value,
182 "Indexes or Dimensions are not compatible with the ^ operator");
183
184 // Definition of Helper constexpr variables
185 constexpr char i = (i0 == i1 || i0 == j1) ? j0 : i0,
186 j = (i1 == i0 || i1 == j0) ? j1 : i1;
187
189 i, j>(TensorExpr(a, b));
190 }
191}
static Number< 2 > N2
static Number< 1 > N1
constexpr double a
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim, Dim, k, j > &b)
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, k, j > &b)
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, j, k > &b)
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim, Dim, j, k > &b)
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
Ddg_Expr< Ddg_carat_Ddg_13< A, B, T, U, Dim, Dim23, i, j, k, l, m, n >, typename promote< T, U >::V, Dim, Dim23, i, k, m, n > operator^(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim23, j, l, m, n > &b)
constexpr AssemblyType A