MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / SECTION

Function SECTION

tests/unit/paulis.cpp:55–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53TEST_CASE( "getPauliStr", TEST_CATEGORY ) {
54
55 SECTION( LABEL_CORRECTNESS ) {
56
57 GENERATE( range(0,10) );
58
59 std::string charSet = GENERATE( "IXYZ", "ixyz", "0123", "iX2z" );
60
61 int numPaulis = GENERATE( 1, 2, 5, 10, 20, 30, 31, 32, 33, 60, 64 );
62 auto targets = getRandomSubRange(0, 64, numPaulis);
63
64 // not necessary to add a terminal char when we specify numPaulis
65 vector<char> pauliChars(numPaulis, 'I');
66 vector<int> pauliInts(numPaulis, 0);
67 long long unsigned lowValue = 0;
68 long long unsigned highValue = 0;
69
70 for (int i=0; i<numPaulis; i++) {
71 int v = getRandomInt(1, 3+1);
72 pauliInts[i] = v;
73 pauliChars[i] = charSet[v];
74
75 int t = targets[i];
76 (t < 32)?
77 (lowValue += v * getPow2(2 * t)): // pow4
78 (highValue += v * getPow2(2 * (t-32))); // pow4
79 }
80
81 SECTION( LABEL_C_INTERFACE ) {
82
83 SECTION( "from chars" ) {
84
85 CAPTURE( targets, pauliChars );
86
87 PauliStr str = getPauliStr(pauliChars.data(), targets.data(), numPaulis);
88
89 REQUIRE( str.lowPaulis == lowValue );
90 REQUIRE( str.highPaulis == highValue );
91 }
92
93 SECTION( "from ints" ) {
94
95 CAPTURE( targets, pauliChars );
96
97 PauliStr str = getPauliStr(pauliInts.data(), targets.data(), numPaulis);
98
99 REQUIRE( str.lowPaulis == lowValue );
100 REQUIRE( str.highPaulis == highValue );
101 }
102
103 SECTION( "from literal" ) {
104
105 // lazily ignores some above prepared vars
106
107 int targ = targets[0];
108 CAPTURE( targ );
109
110 const char* in = "X";
111 PauliStr str = getPauliStr(in, &targ, 1);
112 REQUIRE( str.lowPaulis == ((targ < 32)? getPow2(2*targ) : 0) );

Callers

nothing calls this directly

Calls 13

getRandomSubRangeFunction · 0.85
getPow2Function · 0.85
getPauliStrFunction · 0.85
createPauliStrSumFunction · 0.85
REQUIRE_AGREEFunction · 0.85
getMatrixFunction · 0.85
destroyPauliStrSumFunction · 0.85
createInlinePauliStrSumFunction · 0.85
getQuESTEnvFunction · 0.85
syncQuESTEnvFunction · 0.85

Tested by

no test coverage detected