dq.parity
parity(dim: int, *, layout: Layout | None = None) -> QArray
Returns the parity operator of a bosonic mode.
It is defined by \(P = e^{i\pi a^\dag a}\), where \(a\) and \(a^\dag\) are the annihilation and creation operators, respectively.
Parameters:
-
dim–Dimension of the Hilbert space.
-
layout–Matrix layout (
dq.dense,dq.diaorNone).
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]]