symop.ccr.algebra.op.poly

Operator polynomials.

This module defines OpPoly, a finite linear combination of operator words (OpTerm).

\[\mathcal{O} = \sum_k c_k \, W_k,\]

where each \(W_k\) is an ordered product of ladder operators.

Classes

OpPoly([terms])

Finite linear combination of OpTerm objects.

class OpPoly(terms: tuple[OpTerm, ...] = ()) None

Bases: object

Finite linear combination of OpTerm objects.

Parameters:

terms (tuple[OpTerm, ...]) – Tuple of operator terms.

Notes

Multiplication does not automatically merge like terms; call combine_like_terms() to normalize.

static X_theta(mode: ModeOp, theta: float) OpPoly

Return the rotated quadrature \(X_\theta\).

Parameters:
  • mode (ModeOp)

  • theta (float)

Return type:

OpPoly

static a(mode: ModeOp) OpPoly

Return the annihilation operator for mode.

Parameters:

mode (ModeOp)

Return type:

OpPoly

static adag(mode: ModeOp) OpPoly

Return the creation operator for mode.

Parameters:

mode (ModeOp)

Return type:

OpPoly

adjoint() OpPoly

Return the Hermitian adjoint polynomial.

Return type:

OpPoly

combine_like_terms(*, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) OpPoly

Combine operator terms with identical signatures.

Terms are bucketed either by their exact signatures or, when approx=True, by approximate signatures obtained via OpTermProto.approx_signature().

When approximate matching is enabled, the parameters decimals and ignore_global_phase are forwarded to the underlying signature computation of the ladder operators.

Parameters:
  • approx (bool) – If True, use approximate signatures for bucketing. Otherwise, exact signatures are used.

  • decimals (int) – Number of decimal places used when rounding floating-point quantities in approximate signatures.

  • ignore_global_phase (bool) – If True, component signatures may ignore global phase factors when constructing approximate signatures.

Returns:

A new polynomial with coefficients of identical words summed and zero-sum buckets removed.

Return type:

OpPoly

Notes

This operation performs purely signature-based merging. It does not reorder words or apply commutation relations.

static from_words(words: Iterable[Iterable[LadderOp]], coeffs: Iterable[complex] | None = None) OpPoly

Construct an operator polynomial from words and coefficients.

Parameters:
Return type:

OpPoly

static identity(c: complex = 1.0) OpPoly

Return the identity operator polynomial.

Parameters:

c (complex)

Return type:

OpPoly

property is_identity: bool

Return True iff all terms are empty words and there is at least one.

property is_zero: bool

Return True iff there are no terms.

property mode_count: int

Return the number of unique modes appearing in the polynomial.

static n(mode: ModeOp) OpPoly

Return the number operator \(a^\dagger a\) for mode.

Parameters:

mode (ModeOp)

Return type:

OpPoly

static n2(mode: ModeOp) OpPoly

Return \(n^2\).

Parameters:

mode (ModeOp)

Return type:

OpPoly

normalize(*, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) OpPoly

Return a normalized operator polynomial.

This is a convenience alias for combine_like_terms(). It produces a polynomial in which identical operator words have been merged and zero-coefficient terms removed.

Parameters:
  • approx (bool) – If True, approximate signatures are used for merging.

  • decimals (int) – Decimal precision used for approximate signature rounding.

  • ignore_global_phase (bool) – If True, global phase factors may be ignored in approximate signature comparisons.

Returns:

Normalized operator polynomial.

Return type:

OpPoly

static p(mode: ModeOp) OpPoly

Return the quadrature \(p = (i a^\dagger - i a)/\sqrt{2}\).

Parameters:

mode (ModeOp)

Return type:

OpPoly

static p2(mode: ModeOp) OpPoly

Return \(p^2\).

Parameters:

mode (ModeOp)

Return type:

OpPoly

static q(mode: ModeOp) OpPoly

Return the quadrature \(q = (a + a^\dagger)/\sqrt{2}\).

Parameters:

mode (ModeOp)

Return type:

OpPoly

static q2(mode: ModeOp) OpPoly

Return \(q^2\).

Parameters:

mode (ModeOp)

Return type:

OpPoly

scaled(c: complex) OpPoly

Return a scaled copy.

Parameters:

c (complex)

Return type:

OpPoly

terms: tuple[OpTerm, ...] = ()
property unique_modes: tuple[ModeOp, ...]

Return unique modes appearing in the polynomial (first-seen order).

static x(mode: ModeOp) OpPoly

Alias for q().

Parameters:

mode (ModeOp)

Return type:

OpPoly

static zero() OpPoly

Return the zero operator polynomial.

Return type:

OpPoly