| 2788 | */ |
| 2789 | |
| 2790 | void 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 | |
| 2812 | void validate_superOpFieldsMatchPassedParams(SuperOp op, int numQb, const char* caller) { |
| 2813 |
no test coverage detected