Skip to content

dq.proj

proj(x: ArrayLike) -> Array

Returns the projection operator onto a pure quantum state.

The projection operator onto the state \(\ket\psi\) is defined as \(P_{\ket\psi} = \ket\psi\bra\psi\).

Parameters

  • x (array_like of shape (..., n, 1) or (..., 1, n)) –

    Ket or bra.

Returns

(array of shape (..., n, n)) Projection operator.

Examples

>>> psi = dq.fock(3, 0)
>>> dq.proj(psi)
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]], dtype=complex64)