Operator Terms

This module collects routines that operate on the individual terms of an operator, partitioning them based on their structure. The submodules below group related functionality.

Grouping

Terms may be tagged with group indices via groups, which an Evolution gate then honors by decomposing into one sub-evolution per group. Grouping terms before the boson-to-qubit mapping is what lets a grouping chosen from the problem’s structure survive into the circuit.

No automatic grouping strategy ships yet; assign the indices directly. What this module does provide is the analysis of an existing grouping: group_coeff_means() reduces it to one sampling weight per group, groups_are_hermitian() reports whether each group is separately Hermitian (which a randomized product formula, and Qiskit’s PauliEvolutionGate, require), and groups_have_uniform_coeffs() whether its coefficients are numerically equal.

group_coeff_means(op)

Returns the mean absolute coefficient magnitude of each group.

groups_are_hermitian(op, *[, atol])

Returns, for each group, whether the operator formed by that group's terms is Hermitian.

groups_have_uniform_coeffs(op, *[, atol, abs])

Returns, for each group, whether all of its coefficients are numerically equal.

Filtering

This module provides convenience functions for removing terms from an operator that do not contribute meaningfully to a downstream computation.

Members

filter_diagonal_terms(op)

Filters out the terms of an operator that are diagonal in the occupation-number basis.

Ordering

This module provides functions to reorder the terms of an operator. While the resulting operators are mathematically identical, the term order can have significant implications on algorithm behavior at runtime, due to the term iteration order.

Members

canonical_order(op)

Returns a copy of an operator with its terms sorted into a canonical order.

group_order(op)

Returns a copy of an operator with its terms ordered by group index.

order_terms(op, key, *[, reverse])

Returns a copy of an operator with its terms reordered by a user-provided key.

Group-ordered operators

group_order() makes each group one contiguous run of terms. That layout is what lets split_out_groups() binary-search the requested groups instead of scanning every term, so ordering once up front pays off before repeatedly transpiling with BosonicQDrift, which looks up its sampled groups on every call.