v0.14.0
Loading...
Searching...
No Matches
test_T2_38.cpp
Go to the documentation of this file.
3#include <iostream>
4using namespace FTensor;
5using namespace std;
6
8{
9 Number<0> N0;
10 Number<1> N1;
11 Number<2> N2;
12
13 /* Tensor2 tests */
14
15 /* Checking whether functors work */
16
18 complex<double>(1, 2), complex<double>(3, 4), complex<double>(5, 6),
19 complex<double>(7, 8));
20
21 Index<'a', 2> a;
22 Index<'b', 2> b;
23
24 /* I have this function pointer defined here because I can't seem to
25 make the compiler understand what kind of function I have.
26 Unless I do casts, which are ugly. It seems to have something to
27 do with conj being a templated function. */
28
29 complex<double> (*cj)(const complex<double> &);
30 cj = &(conj<double>);
31
33 conj(t1(0, 0))
34 - transform(t1(a, b),
35 static_cast<complex<double> (*)(const complex<double> &)>(
36 &(conj<double>)))(0, 0),
37 "transform(T2)(0,0) cast");
39 conj(t1(0, 1))
40 - transform(t1(a, b),
41 static_cast<complex<double> (*)(const complex<double> &)>(
42 &(conj<double>)))(0, 1),
43 "transform(T2)(0,1) cast");
45 conj(t1(1, 0))
46 - transform(t1(a, b),
47 static_cast<complex<double> (*)(const complex<double> &)>(
48 &(conj<double>)))(1, 0),
49 "transform(T2)(1,0) cast");
51 conj(t1(1, 1))
52 - transform(t1(a, b),
53 static_cast<complex<double> (*)(const complex<double> &)>(
54 &(conj<double>)))(1, 1),
55 "transform(T2)(1,1) cast");
56 test_for_zero(conj(t1(0, 0)) - transform(t1(a, b), cj)(0, 0),
57 "transform(T2)(0,0)");
58 test_for_zero(conj(t1(0, 1)) - transform(t1(a, b), cj)(0, 1),
59 "transform(T2)(0,1)");
60 test_for_zero(conj(t1(1, 0)) - transform(t1(a, b), cj)(1, 0),
61 "transform(T2)(1,0)");
62 test_for_zero(conj(t1(1, 1)) - transform(t1(a, b), cj)(1, 1),
63 "transform(T2)(1,1)");
64
65 /* Check plain old conj */
66
67 test_for_zero(conj(t1(0, 0)) - conj(t1(a, b))(0, 0), "conj(T2)(0,0)");
68 test_for_zero(conj(t1(0, 1)) - conj(t1(a, b))(0, 1), "conj(T2)(0,1)");
69 test_for_zero(conj(t1(1, 0)) - conj(t1(a, b))(1, 0), "conj(T2)(1,0)");
70 test_for_zero(conj(t1(1, 1)) - conj(t1(a, b))(1, 1), "conj(T2)(1,1)");
71}
Tensors class implemented by Walter Landry.
constexpr double a
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
Tensor2_Expr< conj_Tensor2< A, T, Dim0, Dim1, i, j >, T, Dim0, Dim1, i, j > conj(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a)
Tensor2_Expr< transform_Tensor2< A, B, T, Dim0, Dim1, i, j >, T, Dim0, Dim1, i, j > transform(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a, B function)
void test_T2_38()
Definition test_T2_38.cpp:7
void test_for_zero(const T &t, const std::string &s)