Function applyDiagonalOp

Source
pub unsafe extern "C" fn applyDiagonalOp(qureg: Qureg, op: DiagonalOp)
Expand description

Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire \p qureg.

Let \f$d_j = \text{op.real}[j] + (\text{op.imag}[j]),\text{i} \f$, and \f[ \hat{D} = \begin{pmatrix} d_0 \ & d_1 \ & & \ddots \ & & & d_{2^{\text{op.numQubits}}-1} \end{pmatrix}. \f] If \p qureg is a state-vector \f$|\psi\rangle\f$, this function performs \f$|\psi\rangle \rightarrow \hat{D} , |\psi\rangle\f$. \n If \p qureg is a density-matrix \f$\rho\f$, this function performs \f$\rho \rightarrow \hat{D}, \rho\f$. Notice this has not applied \f$\hat{D}\f$ in the fashion of a unitary.

If your operator is unitary with unit amplitudes, the phases of which can be described by an analytic expression, you should instead use applyPhaseFunc() or applyNamedPhaseFunc() for significant memory and runtime savings.

To apply a diagonal operator upon a specific subset of qubits, use applySubDiagonalOp()

@see

  • createDiagonalOp()
  • calcExpecDiagonalOp()
  • applyPhaseFunc()
  • applyNamedPhaseFunc()
  • applySubDiagonalOp()

@ingroup operator @param[in,out] qureg the state to operate the diagonal operator upon @param[in] op the diagonal operator to apply @throws invalidQuESTInputError()

  • if \p op was not created
  • if \p op acts on a different number of qubits than \p qureg represents @author Tyson Jones