v0.14.0
Functions
test_T2_38.cpp File Reference
#include "../../../src/FTensor.hpp"
#include "../test_for_zero.hpp"
#include <iostream>

Go to the source code of this file.

Functions

void test_T2_38 ()
 

Function Documentation

◆ test_T2_38()

void test_T2_38 ( )

Definition at line 7 of file test_T2_38.cpp.

8 {
9  Number<0> N0;
10  Number<1> N1;
11  Number<2> N2;
12 
13  /* Tensor2 tests */
14 
15  /* Checking whether functors work */
16 
17  Tensor2<complex<double>, 2, 2> t1(
18  complex<double>(1, 2), complex<double>(3, 4), complex<double>(5, 6),
19  complex<double>(7, 8));
20 
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 }
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
FTensor::Number< 0 >
a
constexpr double a
Definition: approx_sphere.cpp:30
test_for_zero
void test_for_zero(const T &t, const std::string &s)
Definition: test_for_zero.hpp:7
FTensor::conj
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)
Definition: conj_Tensor2.hpp:23
FTensor::Index
Definition: Index.hpp:23
FTensor::transform
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)
Definition: Tensor2_transform.hpp:27