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

Function localiser_statevec_multiQubitProjector

quest/src/core/localiser.cpp:2321–2339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2319
2320
2321void localiser_statevec_multiQubitProjector(Qureg qureg, vector<int> qubits, vector<int> outcomes, qreal prob) {
2322
2323 // this routine is always embarrassingly parallel; however, we handle the
2324 // prefix-qubits here so that the backend can receive only the suffix qubits
2325 // and ergo be agnostic to distribution (so that we can e.g. use cuQuantum).
2326 // any rank which has a prefix-qubit inconsistent with outcomes is zero'd
2327
2328 // nodes with all basis states orthogonal to outcomes (because prefix differs) are zero'd
2329 if (!doAnyLocalStatesHaveQubitValues(qureg, qubits, outcomes)) {
2330 accel_statevec_initUniformState_sub(qureg, 0);
2331 return;
2332 }
2333
2334 // all other nodes has some or all states consistent with suffix outcomes
2335 removePrefixQubitsAndStates(qureg, qubits, outcomes);
2336 (qubits.empty())?
2337 localiser_statevec_scaleAmps(qureg, 1/std::sqrt(prob)):
2338 accel_statevec_multiQubitProjector_sub(qureg, qubits, outcomes, prob);
2339}
2340
2341
2342void localiser_densmatr_multiQubitProjector(Qureg qureg, vector<int> qubits, vector<int> outcomes, qreal prob) {

Tested by

no test coverage detected