Skip to content

dq.coherent

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

Returns the ket of a coherent state or a tensor product of coherent states.

Parameters

  • dim –

    Hilbert space dimension of each mode.

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

    Coherent state amplitude for each mode. If dim is a tuple, the last dimension of alpha should match the length of dim.

Returns

(array of shape (..., n, 1)) Ket of the coherent state or tensor product of coherent states, with n = prod(dims).

Examples

Single-mode coherent state \(\ket{\alpha}\):

>>> dq.coherent(4, 0.5)
Array([[0.882+0.j],
       [0.441+0.j],
       [0.156+0.j],
       [0.047+0.j]], dtype=complex64)

Batched single-mode coherent states \(\{\ket{\alpha_0}\!, \ket{\alpha_1}\}\):

>>> dq.coherent(4, [0.5, 0.5j])
Array([[[ 0.882+0.j   ],
        [ 0.441+0.j   ],
        [ 0.156+0.j   ],
        [ 0.047+0.j   ]],

       [[ 0.882+0.j   ],
        [ 0.   +0.441j],
        [-0.156+0.j   ],
        [ 0.   -0.047j]]], dtype=complex64)

Multi-mode coherent state \(\ket{\alpha}\otimes\ket{\beta}\):

>>> dq.coherent((2, 3), (0.5, 0.5j))
Array([[ 0.775+0.j   ],
       [ 0.   +0.386j],
       [-0.146+0.j   ],
       [ 0.423+0.j   ],
       [ 0.   +0.211j],
       [-0.08 +0.j   ]], dtype=complex64)

Batched multi-mode coherent states \(\{\ket{\alpha_0}\otimes\ket{\beta_0}\!, \ket{\alpha_1}\otimes\ket{\beta_1}\}\):

>>> alpha = [(0.5, 0.5j), (0.5j, 0.5)]
>>> dq.coherent((4, 6), alpha).shape
(2, 24, 1)