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

Function SECTION

tests/unit/channels.cpp:48–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46TEST_CASE( "createKrausMap", TEST_CATEGORY ) {
47
48 SECTION( LABEL_CORRECTNESS ) {
49
50 int numQubits = GENERATE( range(1,4) ); // 4qb superop = 8qb matrix = 16 statevec
51 int numMatrices = GENERATE( 1, 2, 10 );
52 CAPTURE( numQubits, numMatrices );
53
54 KrausMap map = createKrausMap(numQubits, numMatrices);
55
56 // verify dimensions
57 REQUIRE( map.numQubits == numQubits );
58 REQUIRE( map.numMatrices == numMatrices );
59 REQUIRE( map.numRows == getPow2(numQubits) );
60
61 // verify superoperator dimensions
62 REQUIRE( map.superop.numQubits == numQubits );
63 REQUIRE( map.superop.numRows == getPow2(2 * numQubits) );
64
65 // verify default fields
66 REQUIRE( *(map.isApproxCPTP) == -1 );
67 REQUIRE( *(map.superop.wasGpuSynced) == 0 );
68
69 // verify pointers
70 REQUIRE( map.matrices != nullptr );
71 REQUIRE( map.superop.cpuElems != nullptr );
72 REQUIRE( map.superop.cpuElemsFlat != nullptr );
73 if (getQuESTEnv().isGpuAccelerated)
74 REQUIRE( map.superop.gpuElemsFlat != nullptr );
75 else
76 REQUIRE( map.superop.gpuElemsFlat == nullptr );
77
78 // verify that all matrices default to zero
79 bool isZero = true;
80 for (qindex i=0; i<map.numMatrices && isZero; i++)
81 for (qindex r=0; r<map.numRows && isZero; r++)
82 for (qindex c=0; c<map.numRows && isZero; c++)
83 isZero = (map.matrices[i][r][c] == qcomp(0,0));
84 REQUIRE( isZero );
85
86 // verify superoperator defaults to zero
87 isZero = true;
88 for (qindex r=0; r<map.superop.numRows && isZero; r++)
89 for (qindex c=0; c<map.superop.numRows && isZero; c++)
90 isZero = (map.superop.cpuElems[r][c] == qcomp(0,0));
91 REQUIRE( isZero );
92
93 destroyKrausMap(map);
94 }
95
96 SECTION( LABEL_VALIDATION ) {
97

Callers

nothing calls this directly

Calls 15

createKrausMapFunction · 0.85
getPow2Function · 0.85
getQuESTEnvFunction · 0.85
destroyKrausMapFunction · 0.85
syncKrausMapFunction · 0.85
setKrausMapFunction · 0.85
REQUIRE_AGREEFunction · 0.85
getSuperOperatorFunction · 0.85
setInlineKrausMapFunction · 0.85
createInlineKrausMapFunction · 0.85
createSuperOpFunction · 0.85
destroySuperOpFunction · 0.85

Tested by

no test coverage detected