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

Function validate_newInlineSuperOpDimMatchesVectors

quest/src/core/validation.cpp:2761–2782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2759}
2760
2761void 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

Callers 1

createInlineSuperOpFunction · 0.85

Calls 2

powerOf2Function · 0.85
assertThatFunction · 0.85

Tested by

no test coverage detected