v0.14.0
test_T4_02.cpp
Go to the documentation of this file.
1 #include "../../../src/FTensor.hpp"
2 #include "../test_for_zero.hpp"
3 #include "../test_ostream.hpp"
4 
5 using namespace FTensor;
6 using namespace std;
7 
9  const Tensor2<double, 4, 3> &t2_4,
10  const Tensor2<double, 3, 4> &t2_5)
11 {
16 
17  for(int ii = 0; ii < 1; ++ii)
18  {
19  for(int jj = 0; jj < 2; ++jj)
20  {
21  test_for_zero((t4_1(i, j, k, l) * t2_5(k, l))(ii, jj)
22  - (t4_1(ii, jj, 0, 0) * t2_5(0, 0)
23  + t4_1(ii, jj, 0, 1) * t2_5(0, 1)
24  + t4_1(ii, jj, 0, 2) * t2_5(0, 2)
25  + t4_1(ii, jj, 0, 3) * t2_5(0, 3)
26  + t4_1(ii, jj, 1, 0) * t2_5(1, 0)
27  + t4_1(ii, jj, 1, 1) * t2_5(1, 1)
28  + t4_1(ii, jj, 1, 2) * t2_5(1, 2)
29  + t4_1(ii, jj, 1, 3) * t2_5(1, 3)
30  + t4_1(ii, jj, 2, 0) * t2_5(2, 0)
31  + t4_1(ii, jj, 2, 1) * t2_5(2, 1)
32  + t4_1(ii, jj, 2, 2) * t2_5(2, 2)
33  + t4_1(ii, jj, 2, 3) * t2_5(2, 3)),
34  "T4(i,j,k,l)*T2(k,l)(" + std::to_string(ii) + ","
35  + std::to_string(jj) + ")");
36  test_for_zero((t2_5(k, l) * t4_1(i, j, k, l))(ii, jj)
37  - (t4_1(ii, jj, 0, 0) * t2_5(0, 0)
38  + t4_1(ii, jj, 0, 1) * t2_5(0, 1)
39  + t4_1(ii, jj, 0, 2) * t2_5(0, 2)
40  + t4_1(ii, jj, 0, 3) * t2_5(0, 3)
41  + t4_1(ii, jj, 1, 0) * t2_5(1, 0)
42  + t4_1(ii, jj, 1, 1) * t2_5(1, 1)
43  + t4_1(ii, jj, 1, 2) * t2_5(1, 2)
44  + t4_1(ii, jj, 1, 3) * t2_5(1, 3)
45  + t4_1(ii, jj, 2, 0) * t2_5(2, 0)
46  + t4_1(ii, jj, 2, 1) * t2_5(2, 1)
47  + t4_1(ii, jj, 2, 2) * t2_5(2, 2)
48  + t4_1(ii, jj, 2, 3) * t2_5(2, 3)),
49  "T2(k,l)*T4(i,j,k,l)(" + std::to_string(ii) + ","
50  + std::to_string(jj) + ")");
51  test_for_zero((t4_1(i, j, k, l) * t2_4(l, k))(ii, jj)
52  - (t4_1(ii, jj, 0, 0) * t2_4(0, 0)
53  + t4_1(ii, jj, 0, 1) * t2_4(1, 0)
54  + t4_1(ii, jj, 0, 2) * t2_4(2, 0)
55  + t4_1(ii, jj, 0, 3) * t2_4(3, 0)
56  + t4_1(ii, jj, 1, 0) * t2_4(0, 1)
57  + t4_1(ii, jj, 1, 1) * t2_4(1, 1)
58  + t4_1(ii, jj, 1, 2) * t2_4(2, 1)
59  + t4_1(ii, jj, 1, 3) * t2_4(3, 1)
60  + t4_1(ii, jj, 2, 0) * t2_4(0, 2)
61  + t4_1(ii, jj, 2, 1) * t2_4(1, 2)
62  + t4_1(ii, jj, 2, 2) * t2_4(2, 2)
63  + t4_1(ii, jj, 2, 3) * t2_4(3, 2)),
64  "T4(i,j,k,l)*T2(l,k)(" + std::to_string(ii) + ","
65  + std::to_string(jj) + ")");
66  test_for_zero((t2_4(l, k) * t4_1(i, j, k, l))(ii, jj)
67  - (t4_1(ii, jj, 0, 0) * t2_4(0, 0)
68  + t4_1(ii, jj, 0, 1) * t2_4(1, 0)
69  + t4_1(ii, jj, 0, 2) * t2_4(2, 0)
70  + t4_1(ii, jj, 0, 3) * t2_4(3, 0)
71  + t4_1(ii, jj, 1, 0) * t2_4(0, 1)
72  + t4_1(ii, jj, 1, 1) * t2_4(1, 1)
73  + t4_1(ii, jj, 1, 2) * t2_4(2, 1)
74  + t4_1(ii, jj, 1, 3) * t2_4(3, 1)
75  + t4_1(ii, jj, 2, 0) * t2_4(0, 2)
76  + t4_1(ii, jj, 2, 1) * t2_4(1, 2)
77  + t4_1(ii, jj, 2, 2) * t2_4(2, 2)
78  + t4_1(ii, jj, 2, 3) * t2_4(3, 2)),
79  "T2(l,k)*T4(i,j,k,l)(" + std::to_string(ii) + ","
80  + std::to_string(jj) + ")");
81  }
82  for(int kk = 0; kk < 3; ++kk)
83  {
84  test_for_zero((t4_1(i, j, k, l) * t2_5(j, l))(ii, kk)
85  - (t4_1(ii, 0, kk, 0) * t2_5(0, 0)
86  + t4_1(ii, 0, kk, 1) * t2_5(0, 1)
87  + t4_1(ii, 0, kk, 2) * t2_5(0, 2)
88  + t4_1(ii, 0, kk, 3) * t2_5(0, 3)
89  + t4_1(ii, 1, kk, 0) * t2_5(1, 0)
90  + t4_1(ii, 1, kk, 1) * t2_5(1, 1)
91  + t4_1(ii, 1, kk, 2) * t2_5(1, 2)
92  + t4_1(ii, 1, kk, 3) * t2_5(1, 3)),
93  "T4(i,j,k,l)*T2(j,l)(" + std::to_string(ii) + ","
94  + std::to_string(kk) + ")");
95  test_for_zero((t2_5(j, l) * t4_1(i, j, k, l))(ii, kk)
96  - (t4_1(ii, 0, kk, 0) * t2_5(0, 0)
97  + t4_1(ii, 0, kk, 1) * t2_5(0, 1)
98  + t4_1(ii, 0, kk, 2) * t2_5(0, 2)
99  + t4_1(ii, 0, kk, 3) * t2_5(0, 3)
100  + t4_1(ii, 1, kk, 0) * t2_5(1, 0)
101  + t4_1(ii, 1, kk, 1) * t2_5(1, 1)
102  + t4_1(ii, 1, kk, 2) * t2_5(1, 2)
103  + t4_1(ii, 1, kk, 3) * t2_5(1, 3)),
104  "T2(j,l)*T4(i,j,k,l)(" + std::to_string(ii) + ","
105  + std::to_string(kk) + ")");
106  test_for_zero((t4_1(i, j, k, l) * t2_4(l, j))(ii, kk)
107  - (t4_1(ii, 0, kk, 0) * t2_4(0, 0)
108  + t4_1(ii, 0, kk, 1) * t2_4(1, 0)
109  + t4_1(ii, 0, kk, 2) * t2_4(2, 0)
110  + t4_1(ii, 0, kk, 3) * t2_4(3, 0)
111  + t4_1(ii, 1, kk, 0) * t2_4(0, 1)
112  + t4_1(ii, 1, kk, 1) * t2_4(1, 1)
113  + t4_1(ii, 1, kk, 2) * t2_4(2, 1)
114  + t4_1(ii, 1, kk, 3) * t2_4(3, 1)),
115  "T4(i,j,k,l)*T2(l,j)(" + std::to_string(ii) + ","
116  + std::to_string(kk) + ")");
117  test_for_zero((t2_4(l, j) * t4_1(i, j, k, l))(ii, kk)
118  - (t4_1(ii, 0, kk, 0) * t2_4(0, 0)
119  + t4_1(ii, 0, kk, 1) * t2_4(1, 0)
120  + t4_1(ii, 0, kk, 2) * t2_4(2, 0)
121  + t4_1(ii, 0, kk, 3) * t2_4(3, 0)
122  + t4_1(ii, 1, kk, 0) * t2_4(0, 1)
123  + t4_1(ii, 1, kk, 1) * t2_4(1, 1)
124  + t4_1(ii, 1, kk, 2) * t2_4(2, 1)
125  + t4_1(ii, 1, kk, 3) * t2_4(3, 1)),
126  "T2(l,j)*T4(i,j,k,l)(" + std::to_string(ii) + ","
127  + std::to_string(kk) + ")");
128  }
129  for(int ll = 0; ll < 4; ++ll)
130  {
131  test_for_zero((t4_1(i, j, k, l) * t2_5(j, k))(ii, ll)
132  - (t4_1(ii, 0, 0, ll) * t2_5(0, 0)
133  + t4_1(ii, 0, 1, ll) * t2_5(0, 1)
134  + t4_1(ii, 0, 2, ll) * t2_5(0, 2)
135  + t4_1(ii, 1, 0, ll) * t2_5(1, 0)
136  + t4_1(ii, 1, 1, ll) * t2_5(1, 1)
137  + t4_1(ii, 1, 2, ll) * t2_5(1, 2)),
138  "T4(i,j,k,l)*T2(j,k)(" + std::to_string(ii) + ","
139  + std::to_string(ll) + ")");
140  test_for_zero((t2_5(j, k) * t4_1(i, j, k, l))(ii, ll)
141  - (t4_1(ii, 0, 0, ll) * t2_5(0, 0)
142  + t4_1(ii, 0, 1, ll) * t2_5(0, 1)
143  + t4_1(ii, 0, 2, ll) * t2_5(0, 2)
144  + t4_1(ii, 1, 0, ll) * t2_5(1, 0)
145  + t4_1(ii, 1, 1, ll) * t2_5(1, 1)
146  + t4_1(ii, 1, 2, ll) * t2_5(1, 2)),
147  "T2(j,k)*T4(i,j,k,l)(" + std::to_string(ii) + ","
148  + std::to_string(ll) + ")");
149  test_for_zero((t4_1(i, j, k, l) * t2_4(k, j))(ii, ll)
150  - (t4_1(ii, 0, 0, ll) * t2_4(0, 0)
151  + t4_1(ii, 0, 1, ll) * t2_4(1, 0)
152  + t4_1(ii, 0, 2, ll) * t2_4(2, 0)
153  + t4_1(ii, 1, 0, ll) * t2_4(0, 1)
154  + t4_1(ii, 1, 1, ll) * t2_4(1, 1)
155  + t4_1(ii, 1, 2, ll) * t2_4(2, 1)),
156  "T4(i,j,k,l)*T2(k,j)(" + std::to_string(ii) + ","
157  + std::to_string(ll) + ")");
158  test_for_zero((t2_4(k, j) * t4_1(i, j, k, l))(ii, ll)
159  - (t4_1(ii, 0, 0, ll) * t2_4(0, 0)
160  + t4_1(ii, 0, 1, ll) * t2_4(1, 0)
161  + t4_1(ii, 0, 2, ll) * t2_4(2, 0)
162  + t4_1(ii, 1, 0, ll) * t2_4(0, 1)
163  + t4_1(ii, 1, 1, ll) * t2_4(1, 1)
164  + t4_1(ii, 1, 2, ll) * t2_4(2, 1)),
165  "T2(k,j)*T4(i,j,k,l)(" + std::to_string(ii) + ","
166  + std::to_string(ll) + ")");
167  }
168  }
169  for(int jj = 0; jj < 2; ++jj)
170  {
171  for(int kk = 0; kk < 3; ++kk)
172  {
173  test_for_zero((t4_1(i, j, k, l) * t2_5(i, l))(jj, kk)
174  - (t4_1(0, jj, kk, 0) * t2_5(0, 0)
175  + t4_1(0, jj, kk, 1) * t2_5(0, 1)
176  + t4_1(0, jj, kk, 2) * t2_5(0, 2)
177  + t4_1(0, jj, kk, 3) * t2_5(0, 3)),
178  "T4(i,j,k,l)*T2(i,l)(" + std::to_string(jj) + ","
179  + std::to_string(kk) + ")");
180  test_for_zero((t2_5(i, l) * t4_1(i, j, k, l))(jj, kk)
181  - (t4_1(0, jj, kk, 0) * t2_5(0, 0)
182  + t4_1(0, jj, kk, 1) * t2_5(0, 1)
183  + t4_1(0, jj, kk, 2) * t2_5(0, 2)
184  + t4_1(0, jj, kk, 3) * t2_5(0, 3)),
185  "T2(i,l)*T4(i,j,k,l)(" + std::to_string(jj) + ","
186  + std::to_string(kk) + ")");
187  test_for_zero((t4_1(i, j, k, l) * t2_4(l, i))(jj, kk)
188  - (t4_1(0, jj, kk, 0) * t2_4(0, 0)
189  + t4_1(0, jj, kk, 1) * t2_4(1, 0)
190  + t4_1(0, jj, kk, 2) * t2_4(2, 0)
191  + t4_1(0, jj, kk, 3) * t2_4(3, 0)),
192  "T4(i,j,k,l)*T2(l,i)(" + std::to_string(jj) + ","
193  + std::to_string(kk) + ")");
194  test_for_zero((t2_4(l, i) * t4_1(i, j, k, l))(jj, kk)
195  - (t4_1(0, jj, kk, 0) * t2_4(0, 0)
196  + t4_1(0, jj, kk, 1) * t2_4(1, 0)
197  + t4_1(0, jj, kk, 2) * t2_4(2, 0)
198  + t4_1(0, jj, kk, 3) * t2_4(3, 0)),
199  "T2(l,i)*T4(i,j,k,l)(" + std::to_string(jj) + ","
200  + std::to_string(kk) + ")");
201  }
202  for(int ll = 0; ll < 4; ++ll)
203  {
204  test_for_zero((t4_1(i, j, k, l) * t2_5(i, k))(jj, ll)
205  - (t4_1(0, jj, 0, ll) * t2_5(0, 0)
206  + t4_1(0, jj, 1, ll) * t2_5(0, 1)
207  + t4_1(0, jj, 2, ll) * t2_5(0, 2)),
208  "T4(i,j,k,l)*T2(i,k)(" + std::to_string(jj) + ","
209  + std::to_string(ll) + ")");
210  test_for_zero((t2_5(i, k) * t4_1(i, j, k, l))(jj, ll)
211  - (t4_1(0, jj, 0, ll) * t2_5(0, 0)
212  + t4_1(0, jj, 1, ll) * t2_5(0, 1)
213  + t4_1(0, jj, 2, ll) * t2_5(0, 2)),
214  "T2(i,k)*T4(i,j,k,l)(" + std::to_string(jj) + ","
215  + std::to_string(ll) + ")");
216  test_for_zero((t4_1(i, j, k, l) * t2_4(k, i))(jj, ll)
217  - (t4_1(0, jj, 0, ll) * t2_4(0, 0)
218  + t4_1(0, jj, 1, ll) * t2_4(1, 0)
219  + t4_1(0, jj, 2, ll) * t2_4(2, 0)),
220  "T4(i,j,k,l)*T2(k,i)(" + std::to_string(jj) + ","
221  + std::to_string(ll) + ")");
222  test_for_zero((t2_4(k, i) * t4_1(i, j, k, l))(jj, ll)
223  - (t4_1(0, jj, 0, ll) * t2_4(0, 0)
224  + t4_1(0, jj, 1, ll) * t2_4(1, 0)
225  + t4_1(0, jj, 2, ll) * t2_4(2, 0)),
226  "T2(k,i)*T4(i,j,k,l)(" + std::to_string(jj) + ","
227  + std::to_string(ll) + ")");
228  }
229  }
230  for(int kk = 0; kk < 3; ++kk)
231  for(int ll = 0; ll < 4; ++ll)
232  {
233  test_for_zero((t4_1(i, j, k, l) * t2_5(i, j))(kk, ll)
234  - (t4_1(0, 0, kk, ll) * t2_5(0, 0)
235  + t4_1(0, 1, kk, ll) * t2_5(0, 1)),
236  "T4(i,j,k,l)*T2(i,j)(" + std::to_string(kk) + ","
237  + std::to_string(ll) + ")");
238  test_for_zero((t2_5(i, j) * t4_1(i, j, k, l))(kk, ll)
239  - (t4_1(0, 0, kk, ll) * t2_5(0, 0)
240  + t4_1(0, 1, kk, ll) * t2_5(0, 1)),
241  "T2(i,j)*T4(i,j,k,l)(" + std::to_string(kk) + ","
242  + std::to_string(ll) + ")");
243  test_for_zero((t4_1(i, j, k, l) * t2_4(j, i))(kk, ll)
244  - (t4_1(0, 0, kk, ll) * t2_4(0, 0)
245  + t4_1(0, 1, kk, ll) * t2_4(1, 0)),
246  "T4(i,j,k,l)*T2(j,i)(" + std::to_string(kk) + ","
247  + std::to_string(ll) + ")");
248  test_for_zero((t2_4(j, i) * t4_1(i, j, k, l))(kk, ll)
249  - (t4_1(0, 0, kk, ll) * t2_4(0, 0)
250  + t4_1(0, 1, kk, ll) * t2_4(1, 0)),
251  "T2(j,i)*T4(i,j,k,l)(" + std::to_string(kk) + ","
252  + std::to_string(ll) + ")");
253  }
254 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
test_for_zero
void test_for_zero(const T &t, const std::string &s)
Definition: test_for_zero.hpp:7
test_T4_02
void test_T4_02(const Tensor4< double, 1, 2, 3, 4 > &t4_1, const Tensor2< double, 4, 3 > &t2_4, const Tensor2< double, 3, 4 > &t2_5)
Definition: test_T4_02.cpp:8
FTensor::Tensor4
Definition: Tensor4_value.hpp:18
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index
Definition: Index.hpp:23
std
Definition: enable_if.hpp:5
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21