monoprop

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_qubits

Functions

func__init__(self, terms, num_qubits) -> None

Initialize the Pauli operator from a term mapping.

paramself
paramtermsMapping[Pauli | str, complex]

Mapping from :class:Pauli terms (or raw full-width strings) to their coefficients.

paramnum_qubitsint | None

Total 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

None
func__len__(self) -> int

Number of terms in the operator.

paramself

Returns

int
func__repr__(self) -> str

Return a string representation of the operator.

paramself

Returns

str
funcisclose(self, other, rtol=1e-05, atol=1e-08) -> bool

Check if two PauliOperators are closely equal (same terms and coefficients).

paramself
paramotherobject

Another PauliOperator to compare with.

paramrtolfloat
= 1e-05

Relative tolerance for coefficient comparison.

paramatolfloat
= 1e-08

Absolute tolerance for coefficient comparison.

Returns

bool

True if the operators have the same qubit count and matching terms, else False.

funcget_majorana_operator(self) -> MajoranaOperator

Convert 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.

paramself

Returns

monoprop.majorana.MajoranaOperator

On this page