peropq.pauli#
Module Contents#
Classes#
Enum class for Pauli gates. |
|
Class representing a Pauli string multiplied by a complex coefficient. |
Functions#
|
- class peropq.pauli.Pauli#
Bases:
enum.EnumEnum class for Pauli gates.
- I = 'I'#
- X = 'X'#
- Y = 'Y'#
- Z = 'Z'#
- class peropq.pauli.PauliString#
Class representing a Pauli string multiplied by a complex coefficient.
- coefficient: complex = 1#
- classmethod from_pauli_sequence(paulis, coeff=1, start_qubit=0)#
Create from a sequence of Paulis.
The Paulis will be placed sequentially on qubits starting from qubit index <start_qubit>
:param paulis a list/tuple of Paulis :param coeff coefficient of the tensor :param start_qubit which qubit to place first Pauli on
- Parameters:
paulis (collections.abc.Sequence[Pauli]) –
coeff (complex) –
start_qubit (int) –
- Return type:
- __post_init__()#
Special dataclass method that runs directly after initialization.
- Return type:
None
- prune()#
Remove any Identities from the string.
- Return type:
- __eq__(other)#
Equality for PauliStrings.
Two PauliStrings are equal if their coefficients are equal and if their Paulis are equal on all qubits. The underlying qubit_pauli_maps may differ (in the number of Identities).
- Parameters:
other (object) –
- Return type:
bool
- get_pauli(qubit)#
Return the pauli at a given qubit.
:param qubit the qubit index to retrieve the Pauli from
- Returns:
the pauli at qubit index <qubit> otherwise, the identity Pauli.I
- Parameters:
qubit (int) –
- Return type:
- update(update_qubit_pauli_map, coeff=None)#
Update the PauliString.
- Parameters:
update_qubit_pauli_map (dict[int, Pauli]) –
coeff (complex | None) –
- Return type:
- __mul__(other)#
Multiply PauliString with a complex number or PauliString.
- Parameters:
other (PauliString | complex) –
- Return type:
- __rmul__(other)#
Multiply PauliString with a complex number or PauliString.
- Parameters:
other (complex) –
- Return type:
- commutes_with(other)#
Return whether this PauliString commutes with given PauliString.
:param other The right side of the Commutator
- Returns:
True if PauliStrings commute, False otherwise
- Parameters:
other (PauliString) –
- Return type:
bool
- normalized_trace()#
Returns 2^(-n)*Tr(self).
The trace is just the coefficient times the product of the traces of the Paulis over all n qubits (including any identities on qubits not explicitly contained in the qubit_pauli_map). Since Tr(Pauli.I) == 2, and Tr(Pauli.X) == Tr(Pauli.Y) == Tr(Pauli.Z) == 0, the result will either be 0 (if any of the Paulis is not the Identity) or self.coefficient (if all paulis are the identity).
- Return type:
complex
- peropq.pauli._pauli_string_mult(pauli_string1, pauli_string2)#
- Parameters:
pauli_string1 (PauliString) –
pauli_string2 (PauliString) –
- Return type: