dq.number
number(dim: int | None = None) -> Array
Returns the number operator of a bosonic mode.
It is defined by \(n = a^\dag a\), where \(a\) and \(a^\dag\) are the annihilation and creation operators, respectively.
Parameters
-
dim
–
Dimension of the Hilbert space.
Returns
(array of shape (dim, dim)) Number operator.
Examples
>>> dq.number(4)
Array([[0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
[0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
[0.+0.j, 0.+0.j, 2.+0.j, 0.+0.j],
[0.+0.j, 0.+0.j, 0.+0.j, 3.+0.j]], dtype=complex64)