| 2759 | } |
| 2760 | |
| 2761 | void validate_newInlineSuperOpDimMatchesVectors(int numDeclaredQubits, vector<vector<qcomp>> matrix, const char* caller) { |
| 2762 | |
| 2763 | // avoid potentially expensive matrix enumeration if validation is anyway disabled |
| 2764 | if (!global_isValidationEnabled) |
| 2765 | return; |
| 2766 | |
| 2767 | qindex numDeclaredRows = powerOf2(2*numDeclaredQubits); |
| 2768 | tokenSubs vars = { |
| 2769 | {"${NUM_DECLARED_QUBITS}", numDeclaredQubits}, |
| 2770 | {"${NUM_DECLARED_ROWS}", numDeclaredRows}, |
| 2771 | {"${GIVEN_DIM}", matrix.size()}}; |
| 2772 | |
| 2773 | // assert the given matrix has the correct number of rows |
| 2774 | assertThat(numDeclaredRows == (qindex) matrix.size(), report::NEW_INLINE_SUPER_OP_MATRIX_WRONG_NUM_ROWS, vars, caller); |
| 2775 | |
| 2776 | // and that each row has the correct length |
| 2777 | for (qindex r=0; r<numDeclaredRows; r++) { |
| 2778 | qindex numGivenCols = matrix[r].size(); |
| 2779 | vars["${GIVEN_DIM}"] = numGivenCols; |
| 2780 | assertThat(numDeclaredRows == numGivenCols, report::NEW_INLINE_SUPER_OP_MATRIX_WRONG_NUM_COLS, vars, caller); |
| 2781 | } |
| 2782 | } |
| 2783 | |
| 2784 | |
| 2785 |
no test coverage detected