dq.momentum
momentum(dim: int, *, layout: Layout | None = None) -> QArray
Returns the momentum operator \(p = i (a^\dag - a) / 2\).
Parameters
-
dim
–
Dimension of the Hilbert space.
-
layout
–
Matrix layout (
dq.dense
,dq.dia
orNone
).
Returns
(qarray of shape (dim, dim)) Momentum operator.
Examples
>>> dq.momentum(3)
QArray: shape=(3, 3), dims=(3,), dtype=complex64, layout=dia, ndiags=2
[[ â‹… 0.-0.5j â‹… ]
[0.+0.5j â‹… 0.-0.707j]
[ â‹… 0.+0.707j â‹… ]]