Skip to content

dq.to_numpy

to_numpy(x: QArrayLike) -> np.ndarray

Convert a qarray-like into a NumPy array.

Parameters

  • x –

    Object to convert.

Returns

NumPy array.

Examples

>>> dq.to_numpy(dq.fock(3, 1))
array([[0.+0.j],
       [1.+0.j],
       [0.+0.j]], dtype=complex64)
>>> dq.to_numpy([qt.sigmax(), qt.sigmay(), qt.sigmaz()])
array([[[ 0.+0.j,  1.+0.j],
        [ 1.+0.j,  0.+0.j]],

       [[ 0.+0.j,  0.-1.j],
        [ 0.+1.j,  0.+0.j]],

       [[ 1.+0.j,  0.+0.j],
        [ 0.+0.j, -1.+0.j]]])