v0.14.0
test_T2_12.cpp
Go to the documentation of this file.
1 #include "../../../src/FTensor.hpp"
2 #include "../test_for_zero.hpp"
3 #include <iostream>
4 using namespace FTensor;
5 using namespace std;
6 
8 {
11 
12  Number<0> N0;
13  Number<1> N1;
14  Number<2> N2;
15 
16  /* Tensor2 tests */
18  t2(i, j) = t2_1(i, j);
19 
20  t2(i, N0) *= 4;
21  t2(i, N1) *= 6;
22  t2(i, N2) *= 8;
23  test_for_zero(t2(0, 0) - (t2_1(0, 0) * 4), "T2(i,N)*=T(0,0)");
24  test_for_zero(t2(1, 0) - (t2_1(1, 0) * 4), "T2(i,N)*=T(1,0)");
25  test_for_zero(t2(2, 0) - (t2_1(2, 0) * 4), "T2(i,N)*=T(2,0)");
26  test_for_zero(t2(0, 1) - (t2_1(0, 1) * 6), "T2(i,N)*=T(0,1)");
27  test_for_zero(t2(1, 1) - (t2_1(1, 1) * 6), "T2(i,N)*=T(1,1)");
28  test_for_zero(t2(2, 1) - (t2_1(2, 1) * 6), "T2(i,N)*=T(2,1)");
29  test_for_zero(t2(0, 2) - (t2_1(0, 2) * 8), "T2(i,N)*=T(0,2)");
30  test_for_zero(t2(1, 2) - (t2_1(1, 2) * 8), "T2(i,N)*=T(1,2)");
31  test_for_zero(t2(2, 2) - (t2_1(2, 2) * 8), "T2(i,N)*=T(2,2)");
32 
33  t2(i, j) = t2_1(i, j);
34  t2(i, N0) /= 2;
35  t2(i, N1) /= 3;
36  t2(i, N2) /= 4;
37 
38  test_for_zero(t2(0, 0) - (t2_1(0, 0) / 2), "T2(i,N)/=T(0,0)");
39  test_for_zero(t2(1, 0) - (t2_1(1, 0) / 2), "T2(i,N)/=T(1,0)");
40  test_for_zero(t2(2, 0) - (t2_1(2, 0) / 2), "T2(i,N)/=T(2,0)");
41  test_for_zero(t2(0, 1) - (t2_1(0, 1) / 3), "T2(i,N)/=T(0,1)");
42  test_for_zero(t2(1, 1) - (t2_1(1, 1) / 3), "T2(i,N)/=T(1,1)");
43  test_for_zero(t2(2, 1) - (t2_1(2, 1) / 3), "T2(i,N)/=T(2,1)");
44  test_for_zero(t2(0, 2) - (t2_1(0, 2) / 4), "T2(i,N)/=T(0,2)");
45  test_for_zero(t2(1, 2) - (t2_1(1, 2) / 4), "T2(i,N)/=T(1,2)");
46  test_for_zero(t2(2, 2) - (t2_1(2, 2) / 4), "T2(i,N)/=T(2,2)");
47 
48  t2(i, j) = t2_1(i, j);
49  const Tensor2<double, 3, 3> t2_const(t2);
50  test_for_zero(t2_const(i, i) - (t2_1(0, 0) + t2_1(1, 1) + t2_1(2, 2)),
51  "T2(i,i)");
52 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2< double, 3, 3 >
FTensor::Number< 0 >
test_T2_12
void test_T2_12(const Tensor2< double, 3, 3 > &t2_1)
Definition: test_T2_12.cpp:7
test_for_zero
void test_for_zero(const T &t, const std::string &s)
Definition: test_for_zero.hpp:7
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
std
Definition: enable_if.hpp:5
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19