dq.parity
parity(dim: int, *, layout: Layout | None = None) -> QArray
Returns the parity operator of a bosonic mode.
It is defined by , where and are the annihilation and creation operators, respectively.
Parameters
-
dim
ā
Dimension of the Hilbert space.
-
layout
ā
Matrix layout (
dq.dense
,dq.dia
orNone
).
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]]