v0.13.2
Loading...
Searching...
No Matches
Ddg_times_Ddg.hpp
Go to the documentation of this file.
1/* Fully contract a Ddg with a Ddg. */
2
3#pragma once
4
5namespace FTensor {
6/* A(i,j,k,l)*B(i,k,j,l) */
7
8template <class A, class B, class T, class U, int Dim, char i, char j, char k,
9 char l, int Current_Dim0, int Current_Dim1, int Current_Dim2,
10 int Current_Dim3>
15 const Number<Current_Dim3> &) {
16 return a(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
17 Current_Dim3 - 1) *
18 b(Current_Dim0 - 1, Current_Dim2 - 1, Current_Dim1 - 1,
19 Current_Dim3 - 1) +
23}
24
25template <class A, class B, class T, class U, int Dim, char i, char j, char k,
26 char l, int Current_Dim1, int Current_Dim2, int Current_Dim3>
27typename promote<T, U>::V
30 const Number<1> &, const Number<Current_Dim1> &,
32 const Number<Current_Dim3> &) {
33 return a(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1) *
34 b(0, Current_Dim2 - 1, Current_Dim1 - 1, Current_Dim3 - 1) +
37}
38
39template <class A, class B, class T, class U, int Dim, char i, char j, char k,
40 char l, int Current_Dim2, int Current_Dim3>
41typename promote<T, U>::V
44 const Number<1> &, const Number<1> &,
46 const Number<Current_Dim3> &) {
47 return a(0, 0, Current_Dim2 - 1, Current_Dim3 - 1) *
48 b(0, Current_Dim2 - 1, 0, Current_Dim3 - 1) +
52}
53
54template <class A, class B, class T, class U, int Dim, char i, char j, char k,
55 char l, int Current_Dim3>
56typename promote<T, U>::V
59 const Number<1> &, const Number<1> &, const Number<1> &,
60 const Number<Current_Dim3> &) {
61 return a(0, 0, 0, Current_Dim3 - 1) * b(0, 0, 0, Current_Dim3 - 1) +
64}
65
66template <class A, class B, class T, class U, int Dim, char i, char j, char k,
67 char l>
68typename promote<T, U>::V
71 const Number<1> &, const Number<1> &, const Number<1> &,
72 const Number<1> &) {
73 return a(0, 0, 0, 0) * b(0, 0, 0, 0);
74}
75
76template <class A, class B, class T, class U, int Dim, char i, char j, char k,
77 char l>
78typename promote<T, U>::V
83}
84
85/* A(m,n,i,j)*B(m,n,k,l) -> Ddg */
86
87template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
88 char i, char j, char k, char l, char m, char n>
90
93
96
97public:
98 Ddg_times_Ddg_0101(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
99
100 template <int Current_Dim0, int Current_Dim1>
101 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
102 const int N4, const Number<Current_Dim0> &,
103 const Number<Current_Dim1> &) const {
104 return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
105 iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
108 }
109 template <int Current_Dim1>
110 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
111 const int N4, const Number<1> &,
112 const Number<Current_Dim1> &) const {
113 return iterA(0, Current_Dim1 - 1, N1, N2) *
114 iterB(0, Current_Dim1 - 1, N3, N4) +
115 eval(N1, N2, N3, N4, Number<Dim45>(),
117 }
118 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
119 const int N4, const Number<1> &,
120 const Number<1> &) const {
121 return iterA(0, 0, N1, N2) * iterB(0, 0, N3, N4);
122 }
123
124 typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
125 const int N4) const {
126 return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
127 }
128};
129
130template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
131 char i, char j, char k, char l, char m, char n>
134 using TensorExpr =
136 return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
137 l>(TensorExpr(a, b));
138}
139
140/* A(i,j, m, n)*B(m,n,k,l) -> Ddg */
141
142template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
143 char i, char j, char k, char l, char m, char n>
145
148
151
152public:
153 Ddg_times_Ddg_2301(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
154
155 template <int Current_Dim0, int Current_Dim1>
156 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
157 const int N4, const Number<Current_Dim0> &,
158 const Number<Current_Dim1> &) const {
159 return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
160 iterB(Current_Dim0 - 1, Current_Dim1 - 1, N3, N4) +
163 }
164 template <int Current_Dim1>
165 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
166 const int N4, const Number<1> &,
167 const Number<Current_Dim1> &) const {
168 return iterA(N1, N2, 0, Current_Dim1 - 1) *
169 iterB(0, Current_Dim1 - 1, N3, N4) +
171 }
172 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
173 const int N4, const Number<1> &,
174 const Number<1> &) const {
175 return iterA(N1, N2, 0, 0) * iterB(0, 0, N3, N4);
176 }
177
178 typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
179 const int N4) const {
180 return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
181 }
182
183};
184
185template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
186 char i, char j, char k, char l, char m, char n>
187Ddg_Expr<Ddg_times_Ddg_2301<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
188 typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
191 using TensorExpr =
193 return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
194 l>(TensorExpr(a, b));
195}
196
197/* A(m,n,i,j)*B(k,l,m,n) -> Ddg */
198
199template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
200 char i, char j, char k, char l, char m, char n>
202
205
208
209public:
210 Ddg_times_Ddg_0123(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
211
212 template <int Current_Dim0, int Current_Dim1>
213 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
214 const int N4, const Number<Current_Dim0> &,
215 const Number<Current_Dim1> &) const {
216 return iterA(Current_Dim0 - 1, Current_Dim1 - 1, N1, N2) *
217 iterB(N3, N4, Current_Dim0 - 1, Current_Dim1 - 1) +
220 }
221 template <int Current_Dim1>
222 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
223 const int N4, const Number<1> &,
224 const Number<Current_Dim1> &) const {
225 return iterA(0, Current_Dim1 - 1, N1, N2) *
226 iterB(N3, N4, 0, Current_Dim1 - 1) +
228 }
229 inline typename promote<T, U>::V eval(const int N1, const int N2, const int N3,
230 const int N4, const Number<1> &,
231 const Number<1> &) const {
232 return iterA(0, 0, N1, N2) * iterB(N3, N4, 0, 0);
233 }
234
235 typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
236 const int N4) const {
237 return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
238 }
239
240
241};
242
243template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
244 char i, char j, char k, char l, char m, char n>
245Ddg_Expr<Ddg_times_Ddg_0123<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
246 typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
249 using TensorExpr =
251 return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
252 l>(TensorExpr(a, b));
253}
254
255/* A(i,j,m,n)*B(k,l,m,n) -> Ddg */
256
257template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
258 char i, char j, char k, char l, char m, char n>
260
263
266
267public:
268 Ddg_times_Ddg_2323(const IterA &a, const IterB &b) : iterA(a), iterB(b) {}
269
270 template <int Current_Dim0, int Current_Dim1>
271 inline typename promote<T, U>::V
272 eval(const int N1, const int N2, const int N3, const int N4,
273 const Number<Current_Dim0> &, const Number<Current_Dim1> &) const {
274 return iterA(N1, N2, Current_Dim0 - 1, Current_Dim1 - 1) *
275 iterB(N3, N4, Current_Dim0 - 1, Current_Dim1 - 1) +
278 }
279 template <int Current_Dim1>
280 inline typename promote<T, U>::V
281 eval(const int N1, const int N2, const int N3, const int N4,
282 const Number<1> &, const Number<Current_Dim1> &) const {
283 return iterA(N1, N2, 0, Current_Dim1 - 1) *
284 iterB(N3, N4, 0, Current_Dim1 - 1) +
286 }
287 inline typename promote<T, U>::V eval(const int N1, const int N2,
288 const int N3, const int N4,
289 const Number<1> &,
290 const Number<1> &) const {
291 return iterA(N1, N2, 0, 0) * iterB(N3, N4, 0, 0);
292 }
293
294 typename promote<T, U>::V operator()(const int N1, const int N2, const int N3,
295 const int N4) const {
296 return eval(N1, N2, N3, N4, Number<Dim45>(), Number<Dim45>());
297 }
298
299};
300
301template <class A, class B, class T, class U, int Dim01, int Dim23, int Dim45,
302 char i, char j, char k, char l, char m, char n>
303Ddg_Expr<Ddg_times_Ddg_2323<A, B, T, U, Dim01, Dim23, Dim45, i, j, k, l, m, n>,
304 typename promote<T, U>::V, Dim01, Dim23, i, j, k, l>
307 using TensorExpr =
309 return Ddg_Expr<TensorExpr, typename promote<T, U>::V, Dim01, Dim23, i, j, k,
310 l>(TensorExpr(a, b));
311}
312
313} // namespace FTensor
static Number< 2 > N2
static Number< 1 > N1
constexpr double a
Ddg_times_Ddg_0101(const IterA &a, const IterB &b)
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
Ddg_times_Ddg_0123(const IterA &a, const IterB &b)
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
Ddg_times_Ddg_2301(const IterA &a, const IterB &b)
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
Ddg_times_Ddg_2323(const IterA &a, const IterB &b)
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< 1 > &, const Number< 1 > &) const
promote< T, U >::V eval(const int N1, const int N2, const int N3, const int N4, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &) const
promote< T, U >::V operator()(const int N1, const int N2, const int N3, const int N4) const
FTensor::Index< 'n', SPACE_DIM > n
FTensor::Index< 'm', SPACE_DIM > m
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
promote< T, U >::V T4ddg_times_T4ddg_0213(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, k, j, l > &b, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
promote< T, U >::V operator*(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, k, j, l > &b)
constexpr AssemblyType A