Skip to content


coherent_dm(dim: int | tuple[int, ...], alpha: ArrayLike) -> Array

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


  • dim (int or tuple of ints)

    Dimension of the Hilbert space of each mode.

  • alpha (array_like)

    Coherent state amplitude of each mode.


(array of shape (n, n)) Density matrix of the coherent state.


>>> dq.coherent_dm(4, 0.5)
Array([[0.779+0.j, 0.389+0.j, 0.137+0.j, 0.042+0.j],
       [0.389+0.j, 0.195+0.j, 0.069+0.j, 0.021+0.j],
       [0.137+0.j, 0.069+0.j, 0.024+0.j, 0.007+0.j],
       [0.042+0.j, 0.021+0.j, 0.007+0.j, 0.002+0.j]], dtype=complex64)
>>> dq.coherent_dm((2, 3), (0.5, 0.5))
Array([[0.6  +0.j, 0.299+0.j, 0.113+0.j, 0.328+0.j, 0.163+0.j, 0.062+0.j],
       [0.299+0.j, 0.149+0.j, 0.056+0.j, 0.163+0.j, 0.081+0.j, 0.031+0.j],
       [0.113+0.j, 0.056+0.j, 0.021+0.j, 0.062+0.j, 0.031+0.j, 0.012+0.j],
       [0.328+0.j, 0.163+0.j, 0.062+0.j, 0.179+0.j, 0.089+0.j, 0.034+0.j],
       [0.163+0.j, 0.081+0.j, 0.031+0.j, 0.089+0.j, 0.044+0.j, 0.017+0.j],
       [0.062+0.j, 0.031+0.j, 0.012+0.j, 0.034+0.j, 0.017+0.j, 0.006+0.j]],      dtype=complex64)