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

\[T_k = c_k \, o_{k,1} o_{k,2} \cdots o_{k,L_k},\]

terms with identical signatures are combined into a single term with coefficient equal to the sum of their coefficients.

Functions

combine_like_terms(terms, *[, approx, ...])

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) – If True, approximate signatures are used via OpTermProto.approx_signature(). Otherwise, exact OpTermProto.signature is 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) – If True global 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.