| 3004 | */ |
| 3005 | |
| 3006 | void 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 | |
| 3029 | void validate_krausMapFieldsMatchPassedParams(KrausMap map, int numQb, int numOps, const char* caller) { |
| 3030 |
no test coverage detected