dq.number
number(*dims: int, layout: Layout | None = None) -> QArray | tuple[QArray, ...]
Returns the number operator of a bosonic mode, or a tuple of number operators for a multi-mode system.
For a single mode, it is defined by , where and are the mode annihilation and creation operators, respectively. If multiple dimensions are provided , it returns a tuple with len(dims) operators , where is the number operator acting on the -th subsystem within the composite Hilbert space of dimension :
Parameters
-
*dims
–
Hilbert space dimension of each mode.
-
layout
–
Matrix layout (
dq.dense
,dq.dia
orNone
).
Returns
(qarray or tuple of qarrays, each of shape (n, n)) Number operator(s), with n = prod(dims).
Examples
Single-mode :
>>> dq.number(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dia, ndiags=1
[[ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ 1.+0.j ⋅ ⋅ ]
[ ⋅ ⋅ 2.+0.j ⋅ ]
[ ⋅ ⋅ ⋅ 3.+0.j]]
Multi-mode and :
>>> na, nb = dq.number(2, 3)
>>> na
QArray: shape=(6, 6), dims=(2, 3), dtype=complex64, layout=dia, ndiags=1
[[ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ 1.+0.j ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ 1.+0.j ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ 1.+0.j]]
>>> nb
QArray: shape=(6, 6), dims=(2, 3), dtype=complex64, layout=dia, ndiags=1
[[ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ 1.+0.j ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ 2.+0.j ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ 1.+0.j ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ 2.+0.j]]