pub unsafe extern "C" fn multiControlledUnitary(
    qureg: Qureg,
    controlQubits: *mut c_int,
    numControlQubits: c_int,
    targetQubit: c_int,
    u: ComplexMatrix2
)
Expand description

Apply a general multiple-control single-target unitary, which can include a global phase factor. Any number of control qubits can be specified, and if all have value 1, the given unitary is applied to the target qubit. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & u_{00} & u_{01}\ & & & u_{10} & u_{11} \end{pmatrix} \f] on the control and target qubits. The given 2x2 ComplexMatrix must be unitary, otherwise an error is thrown.

\f[ \begin{tikzpicture}[scale=.5] \node[draw=none] at (-3.5, 3) {controls}; \node[draw=none] at (-3.5, 0) {target};

\node[draw=none] at (0, 6) {$\vdots$}; \draw (0, 5) – (0, 4);

\draw (-2, 4) – (2, 4); \draw[fill=black] (0, 4) circle (.2); \draw (0, 4) – (0, 2);

\draw (-2, 2) – (2, 2); \draw[fill=black] (0, 2) circle (.2); \draw (0, 2) – (0, 1);

\draw (-2,0) – (-1, 0); \draw (1, 0) – (2, 0); \draw (-1,-1)–(-1,1)–(1,1)–(1,-1)–cycle; \node[draw=none] at (0, 0) {U}; \end{tikzpicture} \f]

@see

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

@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] controlQubits applies unitary if all qubits in this array equal 1 @param[in] numControlQubits number of control qubits @param[in] targetQubit qubit to operate on @param[in] u single-qubit unitary matrix to apply @throws invalidQuESTInputError()

  • if \p numControlQubits is outside [1, \p qureg.numQubitsRepresented])
  • if any qubit index (\p targetQubit or one in \p controlQubits) is outside [0, \p qureg.numQubitsRepresented])
  • if any qubit in \p controlQubits is repeated
  • if \p controlQubits contains \p targetQubit
  • if \p u is not unitary @author Ania Brown (state-vector) @author Tyson Jones (density matrix, doc)