Skip to content

dq.proj

proj(x: QArrayLike) -> QArray

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 (qarray-like of shape (..., n, 1) or (..., 1, n)) –

    Ket or bra.

Returns

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

Examples

>>> psi = dq.fock(3, 0)
>>> dq.proj(psi)
QArray: shape=(3, 3), dims=(3,), dtype=complex64, layout=dense
[[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]]