peropq.pauli_bitstring¶
Classes¶
Class representing efficiently Pauli matrices as bitstrings. |
Functions¶
|
Get an instance of PauliString from a string. |
|
Get the non identity indices. |
|
Get the right power for the multiplication, i.e. (1j)^power. |
|
Multiply two bitstrings. |
|
Return whether two bitstrings representing pauli strings commute. |
Module Contents¶
- class peropq.pauli_bitstring.PauliString(bit_string, coefficient=1.0)¶
Class representing efficiently Pauli matrices as bitstrings.
- Parameters:
bit_string (numpy.typing.NDArray)
coefficient (complex)
- bit_string¶
- coefficient¶
- __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:
- __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
- commutes_with(other)¶
Return whether this PauliString commutes with given PauliString.
- Parameters:
other (PauliString) – The right side of the Commutator
- Returns:
True if PauliStrings commute, False otherwise
- Return type:
bool
- get_pauli(qubit)¶
Return a string indicating the Pauli matrix associated with the input qubit.
- Parameters:
qubit (int)
- Return type:
str
- 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_bitstring.pauli_from_string(string, length, start_qubit=0, coefficient=1.0)¶
Get an instance of PauliString from a string.
- Parameters:
string (str) – represents the pauli string
length (int) – legnth of the Pauli string (i.e. number of qubits)
start_qubit (int) – first qubit to place the Pauli on
coefficent – of the Pauli string
coefficient (complex)
- Returns:
instace of PauliString corresponding to the input string.
- Return type:
- peropq.pauli_bitstring._get_non_identity_indices(bit_string)¶
Get the non identity indices.
- Parameters:
bit_string (numpy.typing.NDArray)
- Return type:
numpy.typing.NDArray
- peropq.pauli_bitstring._get_i_power(bit_string1, bit_string2)¶
Get the right power for the multiplication, i.e. (1j)^power.
- Parameters:
bit_string1 (numpy.typing.NDArray)
bit_string2 (numpy.typing.NDArray)
- Return type:
int
- peropq.pauli_bitstring._pauli_string_mult(pauli_string1, pauli_string2)¶
Multiply two bitstrings.
- Parameters:
pauli_string1 (PauliString)
pauli_string2 (PauliString)
- Return type:
- peropq.pauli_bitstring.bit_string_commutation(bit_string1, bit_string2)¶
Return whether two bitstrings representing pauli strings commute.
- Parameters:
bit_string1 (numpy.typing.NDArray) – first bit_string
bit_string2 (numpy.typing.NDArray) – second bit_string
- Returns:
True if the two bitstrings commute, False otherwise.
- Return type:
bool