PauliOperator
A weighted sum of Pauli terms.
Constructed from a \{term: coefficient\} mapping, where each key is a :class:Pauli
term (or, equivalently, a raw full-width Pauli string like "ZZ", which is read as a
term on qubits 0..len-1). The total qubit count lives here, on the operator, and is
required so a propagator can be built from it directly. A gate generator is also authored
as a :class:PauliOperator (wrapped in :class:~monoprop.circuit.ExpGate) -- bare
:class:Pauli terms are not accepted by ExpGate, since the operator is what carries the
qubit count.
Attributes
attributetermsdict[Pauli, complex]= dict(accumulated)attributenum_qubits= num_qubitsFunctions
func__init__(self, terms, num_qubits) -> NoneInitialize the Pauli operator from a term mapping.
paramselfparamtermsMapping[Pauli | str, complex]Mapping from :class:Pauli terms (or raw full-width strings) to their
coefficients.
paramnum_qubitsint | NoneTotal number of qubits the operator acts on. An operator carries its
own qubit count so a propagator can be built from it directly; every term must
act within 0..num_qubits-1. None defers the qubit count (only reachable
via :meth:_from_terms, e.g. while building a generator whose width is not yet
known); :meth:get_majorana_operator then raises.
Returns
Nonefunc__len__(self) -> intNumber of terms in the operator.
paramselfReturns
intfunc__repr__(self) -> strReturn a string representation of the operator.
paramselfReturns
strfuncisclose(self, other, rtol=1e-05, atol=1e-08) -> boolCheck if two PauliOperators are closely equal (same terms and coefficients).
paramselfparamotherobjectAnother PauliOperator to compare with.
paramrtolfloat= 1e-05Relative tolerance for coefficient comparison.
paramatolfloat= 1e-08Absolute tolerance for coefficient comparison.
Returns
boolTrue if the operators have the same qubit count and matching terms, else False.
funcget_majorana_operator(self) -> MajoranaOperatorConvert the Pauli operator to a MajoranaOperator via Jordan-Wigner.
Each local term is extended to the full num_qubits width (identities filled in)
before the Jordan-Wigner map, so the resulting Majorana indices are global.
paramselfReturns
monoprop.majorana.MajoranaOperator