Function quest_sys::controlledCompactUnitary
source · pub unsafe extern "C" fn controlledCompactUnitary(
qureg: Qureg,
controlQubit: c_int,
targetQubit: c_int,
alpha: Complex,
beta: Complex
)Expand description
Apply a controlled unitary (single control, single target) parameterised by two given complex scalars. Given valid complex numbers \f$\alpha\f$ and \f$\beta\f$, applies the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & \alpha & -\beta^* \ & & \beta & \alpha^* \end{pmatrix} \f] to the control and target qubits. Valid \f$\alpha\f$, \f$\beta\f$ satisfy \f$|\alpha|^2 + |\beta|^2 = 1\f$. The target unitary is general up to a global phase factor.
\f[ \begin{tikzpicture}[scale=.5] \node[draw=none] at (-3.5, 2) {control}; \node[draw=none] at (-3.5, 0) {target};
\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_{\alpha, \beta}$}; \end{tikzpicture} \f]
@see
- compactUnitary()
- controlledUnitary()
- multiControlledUnitary()
- multiStateControlledUnitary()
@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] controlQubit apply the target unitary if this qubit has value 1 @param[in] targetQubit qubit on which to apply the target unitary @param[in] alpha complex unitary parameter (row 1, column 1) @param[in] beta complex unitary parameter (row 2, column 1) @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 alpha, \p beta don’t satisfy |
alpha|^2 + |beta|^2 = 1 @author Ania Brown (state-vector) @author Tyson Jones (density matrix, doc)