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

Function calcProbOfBasisState

quest/src/api/calculations.cpp:224–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222
223
224qreal calcProbOfBasisState(Qureg qureg, qindex index) {
225 validate_quregFields(qureg, __func__);
226 validate_basisStateIndex(qureg, index, __func__);
227
228 // |i><i| = ||(1+2^N)i>>
229 if (qureg.isDensityMatrix)
230 index *= 1 + powerOf2(qureg.numQubits);
231
232 qcomp amp = localiser_statevec_getAmp(qureg, index);
233 qreal prob = (qureg.isDensityMatrix)?
234 std::real(amp):
235 std::norm(amp);
236
237 return prob;
238}
239
240
241qreal calcProbOfQubitOutcome(Qureg qureg, int qubit, int outcome) {

Callers 4

SECTIONFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

validate_quregFieldsFunction · 0.85
validate_basisStateIndexFunction · 0.85
powerOf2Function · 0.85

Tested by

no test coverage detected