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

Function validate_krausMapNewMatrixDims

quest/src/core/validation.cpp:3006–3027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3004 */
3005
3006void validate_krausMapNewMatrixDims(KrausMap map, vector<vector<vector<qcomp>>> matrices, const char* caller) {
3007
3008 // avoid potentially expensive matrix enumeration if validation is anyway disabled
3009 if (!global_isValidationEnabled)
3010 return;
3011
3012 assertThat(map.numMatrices == (int) matrices.size(), report::KRAUS_MAP_INCOMPATIBLE_NUM_NEW_MATRICES,
3013 {{"${NUM_GIVEN}", matrices.size()}, {"${NUM_EXPECTED}", map.numMatrices}}, caller);
3014
3015 // check each given matrix...
3016 for (int i=0; i<map.numMatrices; i++) {
3017
3018 // has a correct number of rows
3019 assertThat(map.numRows == (qindex) matrices[i].size(), report::KRAUS_MAP_NEW_MATRIX_ELEMS_WRONG_NUM_ROWS,
3020 {{"${NUM_QUBITS}", map.numQubits}, {"${NUM_EXPECTED_ROWS}", map.numRows}, {"${NUM_GIVEN_ROWS}", matrices[i].size()}}, caller);
3021
3022 // and that each row has a correct number of elements/columns
3023 for (qindex r=0; r<map.numRows; r++)
3024 assertThat(map.numRows == (qindex) matrices[i][r].size(), report::KRAUS_MAP_NEW_MATRIX_ELEMS_WRONG_ROW_DIM,
3025 {{"${NUM_QUBITS}", map.numQubits}, {"${NUM_EXPECTED_COLS}", map.numRows}, {"${NUM_GIVEN_COLS}", matrices[i][r].size()}}, caller);
3026 }
3027}
3028
3029void validate_krausMapFieldsMatchPassedParams(KrausMap map, int numQb, int numOps, const char* caller) {
3030

Callers 2

setKrausMapFunction · 0.85
setInlineKrausMapFunction · 0.85

Calls 1

assertThatFunction · 0.85

Tested by

no test coverage detected