symop.ccr.algebra.density.partial_trace¶
Partial trace for symbolic density polynomials.
Given a density polynomial on a factorized Hilbert space \(\mathcal{H} = \mathcal{H}_K \otimes \mathcal{H}_T\), this module traces out a subset of modes corresponding to \(\mathcal{H}_T\).
Each density term is \(c\,|L\rangle\langle R|\). We split the left/right monomials into kept and traced parts and contract the traced subsystem:
The overlap \(\langle R^T \mid L^T \rangle\) is evaluated symbolically using the ket inner product.
Functions
|
Partial trace over a subset of modes for a symbolic density polynomial. |
- _split_monomial_by_modes(m: Monomial, trace_sigs: set[Any]) tuple[Monomial, Monomial]¶
Partition a monomial into kept vs traced parts.
Operators whose
op.mode.signatureis not intrace_sigsgo to the kept monomial; those whose signatures are intrace_sigsgo to the traced monomial. The return value is(kept, traced).
- _to_mode_signatures(trace_over_modes: Iterable[object]) set[Any]¶
Normalize a list of modes to a set of
ModeOp.signaturekeys.Accepts a heterogeneous iterable containing any of:
a
ModeOpinstance (itssignatureis used),a
LadderOpinstance (itsmode.signatureis used),a
Monomial(all of itsmode_opssignatures are added),a pre-constructed signature tuple.
Returns a set of signature-tuples suitable for membership checks.
- density_partial_trace(terms: tuple[DensityTerm, ...], trace_over_modes: Iterable[object]) tuple[DensityTerm, ...]¶
Partial trace over a subset of modes for a symbolic density polynomial.
Let the Hilbert space factor as \(\mathcal{H} = \mathcal{H}_K \otimes \mathcal{H}_T\), where \(\mathcal{H}_T\) is the subsystem to be traced out. Each density term is \(c \, |L\rangle \langle R|\). We split the left/right monomials into kept/traced parts and contract the traced pieces:
\[\mathrm{Tr}_T\!\big(c \, |L\rangle\langle R|\big) \;=\; \big(c \, \langle R^T \mid L^T \rangle\big) \; |L^K\rangle\langle R^K|.\]The overlap \(\langle R^T \mid L^T \rangle\) is evaluated symbolically via
ket_inner()on one-term kets built from the traced monomials. Terms with zero contraction are dropped, and identical \(|L^K\rangle\langle R^K|\) terms are merged usingcombine_like_terms_density().- Parameters:
- Returns:
The resulting density polynomial on \(\mathcal{H}_K\) with traced modes removed and coefficients contracted.
- Return type:
tuple[DensityTerm, …]