Skip to content

dq.position

position(dim: int, *, layout: Layout | None = None) -> QArray

Returns the position operator \(x = (a^\dag + a) / 2\).

Parameters

  • dim –

    Dimension of the Hilbert space.

  • layout –

    Matrix layout (dq.dense, dq.dia or None).

Returns

(qarray of shape (dim, dim)) Position operator.

Examples

>>> dq.position(3)
QArray: shape=(3, 3), dims=(3,), dtype=complex64, layout=dia, ndiags=2
[[    â‹…     0.5  +0.j     â‹…    ]
 [0.5  +0.j     â‹…     0.707+0.j]
 [    â‹…     0.707+0.j     â‹…    ]]