Skip to content

dq.fock_dm

fock_dm(dim: int | tuple[int, ...], number: ArrayLike) -> Array

Returns the density matrix of a Fock state or a tensor product of Fock states.

Parameters

  • dim –

    Hilbert space dimension of each mode.

  • number (array_like of shape (...) or (..., len(dim))) –

    Fock state number for each mode, of integer type. If dim is a tuple, the last dimension of number should match the length of dim.

Returns

(array of shape (..., n, n)) Density matrix of the Fock state or tensor product of Fock states, with n = prod(dims).

Examples

Single-mode Fock state \(\ket{1}\):

>>> dq.fock_dm(3, 1)
Array([[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]], dtype=complex64)

Batched single-mode Fock states \(\{\ket{0}\!, \ket{1}\!, \ket{2}\}\):

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

Multi-mode Fock state \(\ket{1,0}\):

>>> dq.fock_dm((3, 2), (1, 0))
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, 1.+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, 0.+0.j]], dtype=complex64)

Batched multi-mode Fock states \(\{\ket{0,0}\!, \ket{0,1}\!, \ket{1,1}\!, \ket{2,0}\}\):

>>> number = [(0, 0), (0, 1), (1, 1), (2, 0)]
>>> dq.fock_dm((3, 2), number).shape
(4, 6, 6)