Skip to content

dq.parity

parity(dim: int, *, layout: Layout | None = None) -> QArray

Returns the parity operator of a bosonic mode.

It is defined by P=eiĻ€a†aP = e^{i\pi a^\dag a}, where aa and a†a^\dag are the annihilation and creation operators, respectively.

Parameters

  • dim –

    Dimension of the Hilbert space.

  • layout –

    Matrix layout (dq.dense, dq.dia or None).

Returns

(qarray of shape (dim, dim)) Parity operator.

Examples

>>> dq.parity(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dia, ndiags=1
[[ 1.+0.j    ā‹…       ā‹…       ā‹…   ]
 [   ā‹…    -1.+0.j    ā‹…       ā‹…   ]
 [   ā‹…       ā‹…     1.+0.j    ā‹…   ]
 [   ā‹…       ā‹…       ā‹…    -1.+0.j]]