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

Function validateAndApplyAnyCtrlAnyTargUnitaryMatrix

quest/src/api/operations.cpp:36–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34// T can be CompMatr, CompMatr1, CompMatr2, DiagMatr, DiagMatr1, DiagMatr2
35template <class T>
36void validateAndApplyAnyCtrlAnyTargUnitaryMatrix(Qureg qureg, int* ctrls, int* states, int numCtrls, int* targs, int numTargs, T matr, const char* caller) {
37 validate_quregFields(qureg, caller);
38 validate_controlsAndTargets(qureg, ctrls, numCtrls, targs, numTargs, caller);
39 validate_controlStates(states, numCtrls, caller);
40 validate_matrixDimMatchesTargets(matr, numTargs, caller); // also checks fields and is-synced
41 validate_matrixIsUnitary(matr, caller); // harmlessly rechecks fields and is-synced
42 if (util_isDenseMatrixType<T>())
43 validate_mixedAmpsFitInNode(qureg, numTargs, caller);
44
45 auto ctrlVec = util_getVector(ctrls, numCtrls);
46 auto stateVec = util_getVector(states, numCtrls);
47 auto targVec = util_getVector(targs, numTargs);
48
49 bool conj = false;
50 localiser_statevec_anyCtrlAnyTargAnyMatr(qureg, ctrlVec, stateVec, targVec, matr, conj);
51
52 if (!qureg.isDensityMatrix)
53 return;
54
55 conj = true;
56 ctrlVec = util_getBraQubits(ctrlVec, qureg);
57 targVec = util_getBraQubits(targVec, qureg);
58 localiser_statevec_anyCtrlAnyTargAnyMatr(qureg, ctrlVec, stateVec, targVec, matr, conj);
59
60 /// @todo
61 /// the above logic always performs two in-turn operations upon density matrices,
62 /// though when matr is diagonal (DiagMatr*), they can be trivially combined into
63 /// a single operation which enumerates the state only once. We perform this
64 /// optimisation for FullStateDiagMatr elsewhere. Consider optimising here too!
65}
66
67
68

Callers 15

applyCompMatr1Function · 0.85
applyControlledCompMatr1Function · 0.85
applyCompMatr2Function · 0.85
applyControlledCompMatr2Function · 0.85
applyCompMatrFunction · 0.85
applyControlledCompMatrFunction · 0.85

Calls 9

validate_quregFieldsFunction · 0.85
validate_controlStatesFunction · 0.85
validate_matrixIsUnitaryFunction · 0.85
util_getVectorFunction · 0.85
util_getBraQubitsFunction · 0.85

Tested by

no test coverage detected