Skip to content

dq.fock_dm

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

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

Parameters

  • dim (int or tuple of ints) –

    Dimension of the Hilbert space of each mode.

  • number (int or tuple of ints) –

    Fock state number of each mode.

Returns

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

Examples

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