density_operator
¶
Density operators (mixed quantum states).
DensityOperator
¶
Bases: Operator
Represent a density operator (mixed quantum state).
The matrix must be square, Hermitian, positive semidefinite, and unit-trace.
Source code in shadowsim/core/density_operator.py
__init__
¶
Initialize a DensityOperator.
Parameter matrix: Dense density matrix.
Source code in shadowsim/core/density_operator.py
from_state
classmethod
¶
from_state(state: State) -> Self
Build the pure-state projector |ψ⟩⟨ψ| from a State.
Source code in shadowsim/core/density_operator.py
trace
¶
purity
¶
Return the purity Tr(ρ²) as a real float.
For a valid density operator on a d-dimensional space the value
lies in [1/d, 1]: 1 for a pure state and 1/d for the
maximally mixed state I/d. Because a density operator is
Hermitian, this equals the squared Frobenius norm of the matrix.
Source code in shadowsim/core/density_operator.py
__str__
¶
__repr__
¶
__eq__
¶
Return whether the density operator equals another.
Density operators whose matrices have different shapes compare unequal.
Source code in shadowsim/core/density_operator.py
__ne__
¶
Return whether the density operator differs from another.
Density operators whose matrices have different shapes compare unequal.