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_qubitsattribute__hash__= NoneFunctions
func__init__(self, terms, num_qubits) -> NoneInitialize 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.
paramselfparamtermsMapping[Pauli | str, complex]paramnum_qubitsint | NoneReturns
Nonefunc__len__(self) -> intNumber of terms in the operator.
paramselfReturns
intfunc__repr__(self) -> strReturn a string representation of the operator.
paramselfReturns
strfunc__eq__(self, other) -> boolEqual when num_qubits and term coefficients match exactly.
paramselfparamotherobjectReturns
boolfuncisclose(self, other, rtol=1e-05, atol=1e-08) -> boolCheck 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.
paramselfparamotherobjectparamrtolfloat= 1e-05paramatolfloat= 1e-08Returns
boolfuncget_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.MajoranaOperatorfuncget_local_operator(self) -> MajoranaOperatorPack 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).
paramselfReturns
monoprop.majorana.MajoranaOperatorfuncall_pairwise_commute(self) -> boolWhether every pair of Pauli terms in the operator commutes.
Returns True exactly when for every pair of Pauli
terms are commuting. Equivalently, the number of qubits for which
and have different non-identity letters is even.
paramselfReturns
boolTrue if all pairs of terms commute, else False.