The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
 TEST_CASE ("getQcomp", TEST_CATEGORY)
 
 TEST_CASE ("complex arithmetic", TEST_CATEGORY)
 

Detailed Description

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "complex arithmetic" ,
TEST_CATEGORY  )

Definition at line 63 of file types.cpp.

63 {
64
65 SECTION( LABEL_CORRECTNESS ) {
66
67 qcomp x;
68 x = 1 + 2_i;
69 x += 3 - 4_i;
70 x -= - 5 + 6_i;
71 x *= - 7 - 8_i;
72 x /= 9 + 10_i;
73
74 qcomp ref = getQcomp(-1303/181., 1126/181.);
75 REQUIRE_AGREE( x, ref );
76 }
77
78 SECTION( LABEL_VALIDATION ) {
79
80 // no validation!
81 SUCCEED( );
82 }
83}
static qcomp getQcomp(qreal re, qreal im)
Definition types.h:91

◆ TEST_CASE() [2/2]

TEST_CASE ( "getQcomp" ,
TEST_CATEGORY  )

TESTS

Definition at line 43 of file types.cpp.

43 {
44
45 SECTION( LABEL_CORRECTNESS ) {
46
47 qreal re = getRandomReal(-10, 10);
48 qreal im = getRandomReal(-10, 10);
49
50 qcomp comp = getQcomp(re, im);
51 REQUIRE( std::real(comp) == re );
52 REQUIRE( std::imag(comp) == im );
53 }
54
55 SECTION( LABEL_VALIDATION ) {
56
57 // no validation!
58 SUCCEED( );
59 }
60}
qreal getRandomReal(qreal min, qreal maxExcl)
Definition random.cpp:63