Skip to content

dq.vector_to_operator

vector_to_operator(x: QArrayLike) -> QArray

Returns the operator version of a vectorized operator.

The matrix AA (shape n×nn\times n) is obtained by stacking horizontally next to each other each group of nn elements of the vectorized column vector A ⁣\kett{A} (shape n2×1n^2\times 1): A ⁣=(abcd)A=(acbd). \kett{A} = \begin{pmatrix} a \\ b \\ c \\ d \end{pmatrix} \to A = \begin{pmatrix} a & c \\ b & d \end{pmatrix}.

Parameters

  • x (qarray-like of shape (..., n^2, 1))

    Vectorized operator.

Returns

(qarray of shape (..., n, n)) Operator.

Examples

>>> Avec = jnp.array([[1 + 1j], [2 + 2j], [3 + 3j], [4 + 4j]])
>>> Avec
Array([[1.+1.j],
       [2.+2.j],
       [3.+3.j],
       [4.+4.j]], dtype=complex64)
>>> dq.vector_to_operator(Avec)
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dense
[[1.+1.j 3.+3.j]
 [2.+2.j 4.+4.j]]