Pauli Algebra
QuantumFlow module for working with the Pauli algebra.
-
class quantumflow.Pauli(*terms: Tuple[Sequence[Qubit], str, float | complex | Expr])
An element of the Pauli algebra.
An element of the Pauli algebra is a sequence of terms, such as
Y(1) - 0.5 Z(1) X(2) Y(4)
where X, Y, Z and I are the 1-qubit Pauli operators.
-
classmethod identity() → Pauli
Return the identity element of the Pauli algebra
-
is_identity() → bool
Returns True if this object is identity Pauli element.
-
is_scalar() → bool
Returns true if this object is a scalar multiple of the Pauli
identity element
-
is_zero() → bool
Return True if this object is the zero Pauli element.
-
on(*qubits: Qubit) → Pauli
Return a copy of this Operation with new qubits
-
rewire(labels: Dict[Qubit, Qubit]) → Pauli
Relabel qubits and return copy of this Operation
-
run(ket: State) → State
Apply the action of this operation upon a pure state
-
classmethod scalar(coefficient: float | complex | Expr) → Pauli
Return a scalar multiple of the Pauli identity element.
-
classmethod sigma(qubit: Qubit, operator: str, coefficient: float | complex | Expr = 1.0) → Pauli
Returns a Pauli operator (‘I’, ‘X’, ‘Y’, or ‘Z’) acting
on the given qubit
-
classmethod term(qubits: Sequence[Qubit], ops: str, coefficient: float | complex | Expr = 1.0) → Pauli
Create an element of the Pauli algebra from a sequence of qubits
and operators. Qubits must be unique and sortable
-
classmethod zero() → Pauli
Return the zero element of the Pauli algebra
-
quantumflow.sX(qubit: Qubit, coefficient: float | complex | Expr = 1) → Pauli
Return the Pauli sigma_X operator acting on the given qubit
-
quantumflow.sY(qubit: Qubit, coefficient: float | complex | Expr = 1) → Pauli
Return the Pauli sigma_Y operator acting on the given qubit
-
quantumflow.sZ(qubit: Qubit, coefficient: float | complex | Expr = 1) → Pauli
Return the Pauli sigma_Z operator acting on the given qubit
-
quantumflow.sI(qubit: Qubit, coefficient: float | complex | Expr = 1) → Pauli
Return the Pauli sigma_I (identity) operator. The qubit is irrelevant,
but kept as an argument for consistency
-
quantumflow.pauli_sum(*elements: Pauli) → Pauli
Return the sum of elements of the Pauli algebra
-
quantumflow.pauli_product(*elements: Pauli) → Pauli
Return the product of elements of the Pauli algebra
-
quantumflow.pauli_pow(pauli: Pauli, exponent: int) → Pauli
Raise an element of the Pauli algebra to a non-negative integer power.
-
quantumflow.paulis_commute(element0: Pauli, element1: Pauli) → bool
Return true if the two elements of the Pauli algebra commute.
i.e. if element0 * element1 == element1 * element0
Derivation similar to arXiv:1405.5749v2 for the check_commutation step in
the Raeisi, Wiebe, Sanders algorithm (arXiv:1108.4318, 2011).
-
quantumflow.pauli_commuting_sets(element: Pauli) → Tuple[Pauli, ...]
Gather the terms of a Pauli polynomial into commuting sets.
Uses the algorithm defined in (Raeisi, Wiebe, Sanders,
arXiv:1108.4318, 2011) to find commuting sets. Except uses commutation
check from arXiv:1405.5749v2
-
quantumflow.paulis_close(pauli0: Pauli, pauli1: Pauli, atol: float = 1e-07) → bool
Returns: True if Pauli elements are almost identical.