Function controlledUnitary

Source
pub unsafe extern "C" fn controlledUnitary(
    qureg: Qureg,
    controlQubit: c_int,
    targetQubit: c_int,
    u: ComplexMatrix2,
)
Expand description

Apply a general controlled unitary (single control, single target), which can include a global phase factor. The given unitary is applied to the target qubit if the control qubit has value 1, effecting the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & u_{00} & u_{01}\ & & u_{10} & u_{11} \end{pmatrix} \f] on the control and target qubits.

@htmlonly

@endhtmlonly

@see

  • ::ComplexMatrix2
  • unitary()
  • multiControlledUnitary()
  • multiStateControlledUnitary()
  • twoQubitUnitary()
  • multiQubitUnitary()

@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] controlQubit apply unitary if this qubit is 1 @param[in] targetQubit qubit to operate on @param[in] u single-qubit unitary matrix to apply @throws invalidQuESTInputError()

  • if either \p controlQubit or \p targetQubit are outside [0, \p qureg.numQubitsRepresented)
  • if \p controlQubit and \p targetQubit are equal
  • if \p u is not unitary @author Ania Brown (state-vector) @author Tyson Jones (density matrix, doc)