Density algebra¶
The density layer represents symbolic density-like operators as finite sums of outer products,
\[\rho \sim \sum_i c_i |L_i\rangle\langle R_i|,\]
where both \(L_i\) and \(R_i\) are normally ordered monomials.
The central object is symop.ccr.density.poly.DensityPoly.
Main ideas¶
Density terms keep left and right monomials explicit. This makes it possible to define symbolic operator actions, traces, purity, Hilbert-Schmidt inner products, and partial traces without constructing matrices.
Constructing a pure density from a ket¶
import symop.viz as viz
from symop.core.operators import ModeOp
from symop.ccr.algebra.ket.poly import KetPoly
from symop.ccr.algebra.density.poly import DensityPoly
from symop.modes.envelopes import GaussianEnvelope
from symop.modes.labels import ModeLabel, Path, Polarization
env = GaussianEnvelope(omega0=1.0, sigma=1.0, tau=0.0)
mode = ModeOp(
label=ModeLabel(
envelope=env,
path=Path("A"),
polarization=Polarization.H(),
),
user_label="a",
)
psi = KetPoly.from_ops(creators=(mode.cre,))
rho = DensityPoly.pure(psi)
viz.display(rho)
Left and right actions¶
Left and right operator actions are kept distinct.
rho_left = rho.apply_left((mode.cre,))
rho_right = rho.apply_right((mode.ann,))
viz.display(rho_left)
viz.display(rho_right)
Main operations¶
symop.ccr.density.poly.DensityPoly.trace()symop.ccr.density.poly.DensityPoly.normalize_trace()symop.ccr.density.poly.DensityPoly.inner()symop.ccr.density.poly.DensityPoly.purity()symop.ccr.density.poly.DensityPoly.partial_trace()
Example: trace and purity¶
rho.trace(), rho.purity()
((1+0j), 1.0)