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

Function validate_krausMapFields

quest/src/core/validation.cpp:3047–3079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3045 */
3046
3047void validate_krausMapFields(KrausMap map, const char* caller) {
3048
3049 tokenSubs vars = {
3050 {"${NUM_QUBITS}", map.numQubits},
3051 {"${NUM_MATRICES}", map.numMatrices},
3052 {"${NUM_ROWS}", map.numRows}};
3053
3054 // assert valid fields
3055 auto msg = report::INVALID_KRAUS_MAP_FIELDS;
3056 assertThat(map.numQubits >= 1, msg, vars, caller);
3057 assertThat(map.numMatrices >= 1, msg, vars, caller);
3058 assertThat(map.numRows == powerOf2(map.numQubits), msg, vars, caller);
3059
3060 // check only outer CPU matrix list is allocated, to avoid expensive enumerating of matrices/rows
3061 assertThat(mem_isOuterAllocated(map.matrices), report::INVALID_KRAUS_MAP_MATRIX_LIST_MEM_PTR, caller);
3062
3063 // assert isApproxCPTP heap flag allocated, and that is has a valid value
3064 assertThat(mem_isAllocated(map.isApproxCPTP), report::INVALID_HEAP_FLAG_PTR, caller);
3065
3066 // and that its value is a boolean
3067 int flag = *map.isApproxCPTP;
3068 bool valid = flag == 0 || flag == 1 || flag == validate_STRUCT_PROPERTY_UNKNOWN_FLAG;
3069 tokenSubs moreVars = {{"${BAD_FLAG}", flag}, {"${UNKNOWN_FLAG}", validate_STRUCT_PROPERTY_UNKNOWN_FLAG}};
3070 assertThat(valid, report::INVALID_HEAP_FLAG_VALUE, moreVars, caller);
3071
3072 // assert the superoperator dimension matches the map's
3073 assertThat(map.numQubits == map.superop.numQubits, report::INVALID_KRAUS_MAP_SUPER_OP_NUM_QUBITS,
3074 {{"${MAP_QUBITS}", map.numQubits}, {"${SUPER_OP_QUBITS}", map.superop.numQubits}}, caller);
3075
3076 // assert the superoperator fields are valid (e.g. dims match, ptrs are valid)
3077 bool isInKrausMap = true;
3078 assertSuperOpFieldsAreValid(map.superop, isInKrausMap, caller);
3079}
3080
3081void validate_krausMapIsSynced(KrausMap map, const char* caller) {
3082

Callers 8

validate_krausMapIsCPTPFunction · 0.85
destroyKrausMapFunction · 0.85
syncKrausMapFunction · 0.85
setKrausMapFunction · 0.85
setInlineKrausMapFunction · 0.85
reportKrausMapFunction · 0.85

Calls 5

assertThatFunction · 0.85
powerOf2Function · 0.85
mem_isOuterAllocatedFunction · 0.85
mem_isAllocatedFunction · 0.85

Tested by

no test coverage detected