Function applyProjector

Source
pub unsafe extern "C" fn applyProjector(
    qureg: Qureg,
    qubit: c_int,
    outcome: c_int,
)
Expand description

Force the target \p qubit of \p qureg into the given classical \p outcome, via a non-renormalising projection.

This function zeroes all amplitudes in the state-vector or density-matrix which correspond to the opposite \p outcome given. Unlike collapseToOutcome(), it does not thereafter normalise \p qureg, and hence may leave it in a non-physical state.

Note there is no requirement that the \p outcome state has a non-zero proability, and hence this function may leave \p qureg in a blank state, like that produced by initBlankState().

@see

  • collapseToOutcome() for a norm-preserving equivalent, like a forced measurement

@ingroup operator @param[in,out] qureg a state-vector or density matrix to modify @param[in] qubit the qubit to which to apply the projector @param[in] outcome the single-qubit outcome (0 or 1) to project \p qubit into @throws invalidQuESTInputError()

  • if \p qubit is outside [0, qureg.numQubitsRepresented)
  • if \p outcome is not in {0,1} @author Tyson Jones