symop.ccr.algebra.ket.poly¶
Symbolic ket polynomials for CCR algebra.
This module defines KetPoly, a small immutable
wrapper around a tuple of ket terms.
A ket polynomial represents a finite expansion
where each \(M_k\) is a normally ordered monomial of ladder operators. All operations are purely symbolic and based on CCR normal ordering and term canonicalization; no matrix representations are used.
Presentation / pretty-printing is intentionally out of scope for this package.
Classes
|
Symbolic ket polynomial. |
- class KetPoly(terms: tuple[KetTerm, ...] = ()) None¶
Bases:
objectSymbolic ket polynomial.
- Parameters:
terms (
tuple[KetTerm,...]) – Tuple of ket terms. Terms are not automatically canonicalized on construction; callcombine_like_terms()when needed.
Notes
The class is intentionally logic-only. It provides algebraic operations and structural queries, but no string/latex rendering.
- apply_word(word: Iterable[LadderOp], *, eps: float = 1e-12) KetPoly¶
Apply an operator word on the left:
word * self.
- apply_words(terms: Iterable[tuple[complex, Iterable[LadderOp]]], *, eps: float = 1e-12) KetPoly¶
Apply a linear combination of operator words on the left.
Interprets
termsas an operator polynomial\[\left(\sum_i c_i W_i\right)\lvert \psi \rangle.\]
- combine_like_terms(*, eps: float = 1e-12, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Return a canonicalized polynomial by merging identical monomials.
- static from_ops(*, creators: Iterable[LadderOp] = (), annihilators: Iterable[LadderOp] = (), coeff: complex = 1.0, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Construct from explicit creators and annihilators.
- static from_word(*, ops: Iterable[LadderOp], eps: float = 1e-12) KetPoly¶
Construct by normal-ordering an operator word.
- inner(other: KetPoly, *, eps: float = 1e-12) complex¶
Return the symbolic inner product
<self|other>.
- is_normalized(*, eps: float = 1e-14) bool¶
Return True if the polynomial has unit norm within tolerance.
- multiply(other: KetPoly, *, eps: float = 1e-12, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Return the symbolic product
self * other.
- _ket_poly_check: KetPolyProtocol¶