symop.ccr.algebra.op.combine¶
Combination of like operator terms.
This module provides normalization utilities for operator polynomials. In particular, it merges terms that share the same operator word (up to exact or approximate signatures) and accumulates their coefficients.
Given a collection of operator terms
terms with identical signatures are combined into a single term with coefficient equal to the sum of their coefficients.
Functions
|
Combine operator terms with identical signatures. |
- combine_like_terms(terms: tuple[OpTerm, ...], *, approx: bool = False, term_factory: Callable[[tuple[LadderOp, ...], complex], OpTermT], decimals: int = 12, ignore_global_phase: bool = False) tuple[OpTermT, ...]¶
Combine operator terms with identical signatures.
Terms are bucketed either by their exact signature or by their approximate signature (when
approx=True). Coefficients are accumulated per bucket and zero-sum buckets are discarded.- Parameters:
terms (
tuple[OpTerm,...]) – Tuple of operator terms to combine.approx (
bool) – IfTrue, approximate signatures are used viaOpTermProto.approx_signature(). Otherwise, exactOpTermProto.signatureis used.term_factory (
Callable[[tuple[LadderOp,...],complex],TypeVar(OpTermT, bound=OpTerm)]) – Callable used to construct output terms from(ops, coeff).decimals (
int) – How many decimals are used in approx case.ignore_global_phase (
bool) – IfTrueglobal phase is ignored in approx case.
- Returns:
Combined operator terms with accumulated coefficients. Buckets whose summed coefficient is exactly zero are removed.
- Return type:
tuple[OpTermT, …]
Notes
This function does not attempt symbolic simplification beyond signature-based bucketing. It assumes that input terms are already in a canonical word ordering if such ordering is required.