The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches

Functions for non-destructively calculating the probabilities of measurement outcomes. More...

Functions

qreal calcProbOfBasisState (Qureg qureg, qindex index)
 
qreal calcProbOfMultiQubitOutcome (Qureg qureg, int *qubits, int *outcomes, int numQubits)
 
qreal calcProbOfQubitOutcome (Qureg qureg, int qubit, int outcome)
 
void calcProbsOfAllMultiQubitOutcomes (qreal *outcomeProbs, Qureg qureg, int *qubits, int numQubits)
 

Detailed Description

Functions for non-destructively calculating the probabilities of measurement outcomes.

Function Documentation

◆ calcProbOfBasisState()

qreal calcProbOfBasisState ( Qureg qureg,
qindex index )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 219 of file calculations.cpp.

219 {
220 validate_quregFields(qureg, __func__);
221 validate_basisStateIndex(qureg, index, __func__);
222
223 // |i><i| = ||(1+2^N)i>>
224 if (qureg.isDensityMatrix)
225 index *= 1 + powerOf2(qureg.numQubits);
226
227 qcomp amp = localiser_statevec_getAmp(qureg, index);
228 qreal prob = (qureg.isDensityMatrix)?
229 std::real(amp):
230 std::norm(amp);
231
232 return prob;
233}

Referenced by TEST_CASE().

◆ calcProbOfMultiQubitOutcome()

qreal calcProbOfMultiQubitOutcome ( Qureg qureg,
int * qubits,
int * outcomes,
int numQubits )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 246 of file calculations.cpp.

246 {
247 validate_quregFields(qureg, __func__);
248 validate_targets(qureg, qubits, numQubits, __func__);
249 validate_measurementOutcomesAreValid(outcomes, numQubits, __func__);
250
251 auto qubitVec = util_getVector(qubits, numQubits);
252 auto outcomeVec = util_getVector(outcomes, numQubits);
253
254 return (qureg.isDensityMatrix)?
255 localiser_densmatr_calcProbOfMultiQubitOutcome(qureg, qubitVec, outcomeVec):
256 localiser_statevec_calcProbOfMultiQubitOutcome(qureg, qubitVec, outcomeVec);
257}

Referenced by applyForcedMultiQubitMeasurement(), calcProbOfQubitOutcome(), and TEST_CASE().

◆ calcProbOfQubitOutcome()

qreal calcProbOfQubitOutcome ( Qureg qureg,
int qubit,
int outcome )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 236 of file calculations.cpp.

236 {
237 validate_quregFields(qureg, __func__);
238 validate_target(qureg, qubit, __func__);
239 validate_measurementOutcomeIsValid(outcome, __func__);
240
241 int numQubits = 1;
242 return calcProbOfMultiQubitOutcome(qureg, &qubit, &outcome, numQubits);
243}
qreal calcProbOfMultiQubitOutcome(Qureg qureg, int *qubits, int *outcomes, int numQubits)

Referenced by applyForcedQubitMeasurement(), applyQubitMeasurementAndGetProb(), and TEST_CASE().

◆ calcProbsOfAllMultiQubitOutcomes()

void calcProbsOfAllMultiQubitOutcomes ( qreal * outcomeProbs,
Qureg qureg,
int * qubits,
int numQubits )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 260 of file calculations.cpp.

260 {
261 validate_quregFields(qureg, __func__);
262 validate_targets(qureg, qubits, numQubits, __func__);
263 validate_measurementOutcomesFitInGpuMem(qureg, numQubits, __func__);
264
265 auto qubitVec = util_getVector(qubits, numQubits);
266
267 (qureg.isDensityMatrix)?
268 localiser_densmatr_calcProbsOfAllMultiQubitOutcomes(outcomeProbs, qureg, qubitVec):
269 localiser_statevec_calcProbsOfAllMultiQubitOutcomes(outcomeProbs, qureg, qubitVec);
270}

Referenced by applyMultiQubitMeasurementAndGetProb(), and TEST_CASE().