pub unsafe extern "C" fn controlledTwoQubitUnitary(
qureg: Qureg,
controlQubit: c_int,
targetQubit1: c_int,
targetQubit2: c_int,
u: ComplexMatrix4,
)Expand description
Apply a general controlled two-qubit unitary (including a global phase factor). The given unitary is applied to the target amplitudes where the control qubit has value 1. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & 1 \ & & & 1 \ & & & & u_{00} & u_{01} & u_{02} & u_{03} \ & & & & u_{10} & u_{11} & u_{12} & u_{13} \ & & & & u_{20} & u_{21} & u_{22} & u_{23} \ & & & & u_{30} & u_{31} & u_{32} & u_{33} \end{pmatrix} \f] on the control and target qubits.
\p targetQubit1 is treated as the \p least significant qubit in \p u, such that a row in \p u is dotted with the vector \f$ |\text{targetQubit2} ;; \text{targetQubit1}\rangle : { |00\rangle, |01\rangle, |10\rangle, |11\rangle } \f$
The passed 4x4 ComplexMatrix must be unitary, otherwise an error is thrown.
@htmlonly
Note that in distributed mode, this routine requires that each node contains at least 4 amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q/4 nodes.
@see
- ::ComplexMatrix4
- multiControlledTwoQubitUnitary()
- multiQubitUnitary()
- unitary()
@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] controlQubit the control qubit which must be in state 1 to effect the given unitary @param[in] targetQubit1 first qubit to operate on, treated as least significant in \p u @param[in] targetQubit2 second qubit to operate on, treated as most significant in \p u @param[in] u unitary matrix to apply @throws invalidQuESTInputError()
- if \p controlQubit, \p targetQubit1 or \p targetQubit2 are outside [0, \p qureg.numQubitsRepresented)
- if any of \p controlQubit, \p targetQubit1 and \p targetQubit2 are equal
- if matrix \p u is not unitary
- if each node cannot fit 4 amplitudes in distributed mode. @author Tyson Jones