pub unsafe extern "C" fn controlledMultiQubitUnitary(
qureg: Qureg,
ctrl: c_int,
targs: *mut c_int,
numTargs: c_int,
u: ComplexMatrixN,
)Expand description
Apply a general controlled multi-qubit unitary (including a global phase factor).
One control and any number of target qubits can be specified.
This effects the many-qubit unitary
\f[
\begin{pmatrix}
1 \
& 1 \
& & 1 \
& & & 1 \
& & & & u_{00} & u_{01} & \dots \
& & & & u_{10} & u_{11} & \dots \
& & & & \vdots & \vdots & \ddots
\end{pmatrix}
\f]
on the control and target qubits.
The target qubits in \p targs are treated as ordered least significant to most significant in \p u.
The passed ComplexMatrix must be unitary and be a compatible size with the specified number of target qubits, otherwise an error is thrown.
@htmlonly
Note that in multithreaded mode, each thread will clone 2^\p numTargs amplitudes, and store these in the runtime stack. Using t threads, the total memory overhead of this function is t*2^\p numTargs. For many targets (e.g. 16 qubits), this may cause a stack-overflow / seg-fault (e.g. on a 1 MiB stack).
Note too that in distributed mode, this routine requires that each node contains at least 2^\p numTargs amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q / 2^\p numTargs nodes.
@see
- createComplexMatrixN()
- multiQubitUnitary()
- multiControlledMultiQubitUnitary()
@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] ctrl the control qubit @param[in] targs a list of the target qubits, ordered least to most significant @param[in] numTargs the number of target qubits @param[in] u unitary matrix to apply @throws invalidQuESTInputError()
- if \p ctrl or any index in \p targs is outside of [0, \p qureg.numQubitsRepresented)
- if \p targs are not unique
- if \p targs contains \p ctrl
- if matrix \p u is not unitary
- if matrix \p u is not of a compatible size with \p numTargs
- if a node cannot fit the required number of target amplitudes in distributed mode @author Tyson Jones