pub unsafe extern "C" fn multiControlledTwoQubitUnitary(
qureg: Qureg,
controlQubits: *mut c_int,
numControlQubits: c_int,
targetQubit1: c_int,
targetQubit2: c_int,
u: ComplexMatrix4,
)Expand description
Apply a general multi-controlled two-qubit unitary (including 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_{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
- twoQubitUnitary()
- controlledTwoQubitUnitary()
- multiQubitUnitary()
- unitary()
@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] controlQubits the control qubits which all must be in state 1 to effect the given unitary @param[in] numControlQubits the number of control qubits @param[in] targetQubit1 first target qubit, treated as least significant in \p u @param[in] targetQubit2 second target qubit, treated as most significant in \p u @param[in] u unitary matrix to apply @throws invalidQuESTInputError()
- if \p targetQubit1 or \p targetQubit2 are outside [0, \p qureg.numQubitsRepresented)
- if \p targetQubit1 equals \p targetQubit2
- if any qubit in \p controlQubits is outside [0, \p qureg.numQubitsRepresented)
- if \p controlQubits are not unique
- if either \p targetQubit1 and \p targetQubit2 are in \p controlQubits
- if matrix \p u is not unitary
- if each node cannot fit 4 amplitudes in distributed mode @author Tyson Jones