Function multiControlledMultiQubitUnitary

Source
pub unsafe extern "C" fn multiControlledMultiQubitUnitary(
    qureg: Qureg,
    ctrls: *mut c_int,
    numCtrls: c_int,
    targs: *mut c_int,
    numTargs: c_int,
    u: ComplexMatrixN,
)
Expand description

Apply a general multi-controlled multi-qubit unitary (including a global phase factor). Any number of control and target qubits can be specified. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & 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 ::ComplexMatrixN must be unitary and be a compatible size with the specified number of target qubits, otherwise an error is thrown.

To left-multiply a non-unitary ::ComplexMatrixN, including control qubits, use applyMultiControlledMatrixN()

@htmlonly

@endhtmlonly

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 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()
  • applyMultiControlledGateMatrixN()
  • applyMultiControlledMatrixN()
  • multiControlledMultiQubitNot()
  • controlledMultiQubitUnitary()
  • multiQubitUnitary()

@ingroup unitary @param[in,out] qureg object representing the set of all qubits @param[in] ctrls a list of the control qubits @param[in] numCtrls the number of control qubits @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 any qubit in \p ctrls and \p targs is invalid, i.e. outside [0, qureg.numQubitsRepresented)
  • if \p ctrls or \p targs contain any repetitions
  • if any qubit in \p ctrls is also in \p targs (and vice versa)
  • if \p numTargs < 1
  • if \p numCtrls < 1 (use multiQubitUnitary() for no controls)
  • 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 @throws segmentation-fault
  • if \p ctrls contains fewer elements than \p numCtrls
  • if \p targs contains fewer elements than \p numTargs @author Tyson Jones