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

PauliOperator is always interpreted in the Jordan-Wigner basis.

Attributes

attributetermsdict[Pauli, complex]
= dict(accumulated)
attributenum_qubits
= num_qubits
attribute__hash__
= None

Functions

func__init__(self, terms, num_qubits) -> None

Initialize the Pauli operator from a term mapping.

Every term must act within 0..num_qubits-1. num_qubits=None defers the qubit count (useful while building a generator whose width is not yet known), but then get_majorana_operator and get_local_operator raise.

paramself
paramtermsMapping[Pauli | str, complex]
paramnum_qubitsint | None

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
func__eq__(self, other) -> bool

Equal when num_qubits and term coefficients match exactly.

paramself
paramotherobject

Returns

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

Check whether two PauliOperators have the same terms and close coefficients.

Coefficients are compared with numpy.isclose at rtol/atol; a differing qubit count is False, not an error.

paramself
paramotherobject
paramrtolfloat
= 1e-05
paramatolfloat
= 1e-08

Returns

bool
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
funcget_local_operator(self) -> MajoranaOperator

Pack the operator into the engine's native Pauli basis, as a MajoranaOperator.

Each term maps to its per-qubit gamma-slots -- X_q -> \{2q\}, Y_q -> \{2q+1\}, Z_q -> \{2q, 2q+1\} (see _pauli_to_local_slots) -- carrying its coefficient unchanged; a Hermitian Pauli operator's coefficients are real, but that is not checked here. The result is a MajoranaOperator only as a container for those slot tuples; it is not the Jordan-Wigner image (that is get_majorana_operator).

paramself

Returns

monoprop.majorana.MajoranaOperator
funcall_pairwise_commute(self) -> bool

Whether every pair of Pauli terms in the operator commutes.

Returns True exactly when for every pair of Pauli terms P1,P2P_1, P_2 are commuting. Equivalently, the number of qubits for which P1P_1 and P2P_2 have different non-identity letters is even.

paramself

Returns

bool

True if all pairs of terms commute, else False.

On this page