ApplyDiagonalUnitary operation

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Canon

Package: Microsoft.Quantum.Standard

Applies an array of complex phases to numeric basis states of a register of qubits.

operation ApplyDiagonalUnitary (coefficients : Double[], qubits : Microsoft.Quantum.Arithmetic.LittleEndian) : Unit is Adj + Ctl

Description

This operation implements a diagonal unitary that applies a complex phase $e^{i \theta_j}$ on the $n$-qubit number state $\ket{j}$. In particular, this operation can be represented by the unitary

$$ \begin{align} U = \sum^{2^n-1}_{j=0}e^{i\theta_j}\ket{j}\bra{j}. \end{align} $$

Input

coefficients : Double[]

Array of up to $2^n$ coefficients $\theta_j$. The $j$th coefficient indexes the number state $\ket{j}$ encoded in little-endian format.

qubits : LittleEndian

$n$-qubit control register that encodes number states $\ket{j}$ in little-endian format.

Output : Unit

Remarks

coefficients will be padded with elements $\theta_j = 0.0$ if fewer than $2^n$ are specified.

References

See Also