Skip to content

dq.number

number(*dims: int) -> Array | tuple[Array, ...]

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 \(N = a^\dag a\), where \(a\) and \(a^\dag\) are the mode annihilation and creation operators, respectively. If multiple dimensions are provided \(\mathtt{dims}=(n_1,\dots,n_M)\), it returns a tuple with len(dims) operators \((N_1,\dots,N_M)\), where \(N_k\) is the number operator acting on the \(k\)-th subsystem within the composite Hilbert space of dimension \(n=\prod n_k\): $$ N_k = I_{n_1} \otimes\dots\otimes a_{n_k}^\dag a_{n_k} \otimes\dots\otimes I_{n_M}. $$

Parameters

  • *dims –

    Hilbert space dimension of each mode.

Returns

(array or tuple of arrays, each of shape (n, n)) Number operator(s), with n = prod(dims).

Examples

Single-mode \(a^\dag a\):

>>> 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)

Multi-mode \(a^\dag a \otimes I_3\) and \(I_2\otimes b^\dag b\):

>>> na, nb = dq.number(2, 3)
>>> na
Array([[0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 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, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]], dtype=complex64)
>>> nb
Array([[0.+0.j, 0.+0.j, 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],
       [0.+0.j, 0.+0.j, 2.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 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, 0.+0.j, 0.+0.j, 2.+0.j]], dtype=complex64)