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

Function validate_superOpNewMatrixDims

quest/src/core/validation.cpp:2790–2810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2788 */
2789
2790void validate_superOpNewMatrixDims(SuperOp op, vector<vector<qcomp>> matrix, const char* caller) {
2791
2792 // avoid potentially expensive matrix enumeration if validation is anyway disabled
2793 if (!global_isValidationEnabled)
2794 return;
2795
2796 tokenSubs vars = {
2797 {"${NUM_QUBITS}", op.numQubits},
2798 {"${EXPECTED_DIM}", op.numRows},
2799 {"${GIVEN_DIM}", matrix.size()}};
2800
2801 // assert the matrix has the correct number of rows
2802 assertThat(op.numRows == (qindex) matrix.size(), report::SUPER_OP_NEW_MATRIX_ELEMS_WRONG_NUM_ROWS, vars, caller);
2803
2804 // and that each row has the correct length
2805 for (qindex r=0; r<op.numRows; r++) {
2806 qindex numCols = matrix[r].size();
2807 vars["${GIVEN_DIM}"] = numCols;
2808 assertThat(op.numRows == numCols, report::SUPER_OP_NEW_MATRIX_ELEMS_WRONG_NUM_COLS, vars, caller);
2809 }
2810}
2811
2812void validate_superOpFieldsMatchPassedParams(SuperOp op, int numQb, const char* caller) {
2813

Callers 2

setSuperOpFunction · 0.85
setInlineSuperOpFunction · 0.85

Calls 1

assertThatFunction · 0.85

Tested by

no test coverage detected