Function multiControlledMultiQubitNot

Source
pub unsafe extern "C" fn multiControlledMultiQubitNot(
    qureg: Qureg,
    ctrls: *mut c_int,
    numCtrls: c_int,
    targs: *mut c_int,
    numTargs: c_int,
)
Expand description

Apply a NOT (or Pauli X) gate with multiple control and target qubits. This applies pauliX to qubits \p targs on every basis state for which the control qubits \p ctrls are all in the \f$|1\rangle\f$ state. The ordering within each of \p ctrls and \p targs has no effect on the operation.

This function is equivalent, but significantly faster (approximately \p numTargs times) than applying controlled NOTs on each qubit in \p targs in turn, since: \f[ C_{a, ,b, ,\dots}( X_c \otimes X_d \otimes \dots ) \equiv C_{a, ,b, ,\dots}( X_c) ; \otimes ; C_{a, ,b, ,\dots}(X_d) ; \otimes ; \dots \f]

The effected unitary, if \p targs and \p ctrls happened to be contiguous, has matrix: \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & & & & {{\scriptstyle\cdot}^{{\scriptstyle\cdot}^{{\scriptstyle\cdot}}}} \ & & & & & 1 & \ & & & & 1 & & \ & & & {{\scriptstyle\cdot}^{{\scriptstyle\cdot}^{{\scriptstyle\cdot}}}} & & & \end{pmatrix} \f] and circuit diagram: @htmlonly

@endhtmlonly > In distributed mode, this operation requires at most a single round of pair-wise > communication between nodes, and hence is as efficient as pauliX().

@see

  • multiQubitNot()
  • controlledNot()
  • pauliX()

@ingroup unitary @param[in,out] qureg a state-vector or density matrix to modify @param[in] ctrls a list of the control qubit indices @param[in] numCtrls the length of list \p ctrls @param[in] targs a list of the qubits to be targeted by the X gates @param[in] numTargs the length of list \p targs @throws invalidQuESTInputError()

  • if any qubit in \p ctrls and \p targs is invalid, i.e. outside [0, qureg.numQubitsRepresented)
  • if \p ctrls or \p targs contain any repetitions
  • if any qubit in \p ctrls is also in \p targs (and vice versa)
  • if \p numTargs < 1
  • if \p numCtrls < 1 (use multiQubitNot() for no controls) @throws segmentation-fault
  • if \p ctrls contains fewer elements than \p numCtrls
  • if \p targs contains fewer elements than \p numTargs @author Tyson Jones