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