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

Function getRefProbInner

tests/utils/measure.cpp:61–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61qreal getRefProbInner(auto& state, vector<int> targets, vector<int> outcomes) {
62 DEMAND( getLog2(state.size()) > *std::max_element(targets.begin(), targets.end()) );
63 DEMAND( targets.size() == outcomes.size() );
64
65 // <psi| (|o><o| (x) I) |psi> = Tr( (|o><o| (x) I) rho)
66 int numQubits = getLog2(state.size());
67 qmatrix projector = getProjector(targets, outcomes, numQubits);
68 qcomp value = getReferenceExpectationValue(state, projector); // ~0
69 return std::real(value);
70}
71qreal getReferenceProbability(qvector state, vector<int> targets, vector<int> outcomes) { return getRefProbInner(state, targets, outcomes); }
72qreal getReferenceProbability(qmatrix state, vector<int> targets, vector<int> outcomes) { return getRefProbInner(state, targets, outcomes); }
73

Callers 1

getReferenceProbabilityFunction · 0.85

Calls 3

getLog2Function · 0.85
getProjectorFunction · 0.85

Tested by

no test coverage detected