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

Function assertMatrixDimMatchesTargs

quest/src/core/validation.cpp:2551–2567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2549
2550template <class T>
2551void assertMatrixDimMatchesTargs(T matr, int numTargs, const char* caller) {
2552
2553 validate_matrixFields(matr, caller);
2554
2555 if constexpr (util_isHeapMatrixType<T>())
2556 validate_matrixIsSynced(matr, caller);
2557
2558 int numMatrQubits = 1; // CompMatr1 or DiagMatr1
2559 if constexpr (util_isCompMatr2<T>() || util_isDiagMatr2<T>())
2560 numMatrQubits = 2;
2561 if constexpr (util_isHeapMatrixType<T>())
2562 numMatrQubits = matr.numQubits;
2563
2564 // note (numMatrQubits <= qureg.numQubits) was prior validated by numTargs <= qureg.numQubits
2565 tokenSubs vars = {{"${MATRIX_NUM_QUBITS}", numMatrQubits}, {"${NUM_TARGS}", numTargs}};
2566 assertThat(numMatrQubits == numTargs, report::MATRIX_SIZE_MISMATCHES_NUM_TARGETS, vars, caller);
2567}
2568
2569void validate_matrixDimMatchesTargets(CompMatr1 matr, int numTargs, const char* caller) { assertMatrixDimMatchesTargs(matr, numTargs, caller); }
2570void validate_matrixDimMatchesTargets(CompMatr2 matr, int numTargs, const char* caller) { assertMatrixDimMatchesTargs(matr, numTargs, caller); }

Callers 1

Calls 3

validate_matrixFieldsFunction · 0.85
validate_matrixIsSyncedFunction · 0.85
assertThatFunction · 0.85

Tested by

no test coverage detected