qib.operator.pauli_operator.PauliString¶
- class qib.operator.pauli_operator.PauliString(z, x, q)[source]¶
Bases:
AbstractOperatorPauli string (sequence of identity and Pauli matrices X, Y, Z), together with a global phase factor.
Using check matrix representation (similar to Qiskit convention) by storing binary arrays z and x. The logical Pauli string is
\[(-i)^q \otimes_{k=0}^{n-1} (-i)^{z_k x_k} Z^{z_k} X^{x_k}\]Using convention that Pauli matrix at site 0 corresponds to slowest varying index.
Methods
Generate the sparse matrix representation of the Pauli string.
Test whether the Pauli string commutes with another Pauli string.
List of fields the Pauli string acts on.
Construct a Pauli string from a list of single Pauli matrices, like ('Y', 1), ('X', 4), ('Z', 5).
Construct a Pauli string from a literal string representation, like "iYZXZ".
Get the Pauli matrix at index i as string 'I', 'X', 'Y' or 'Z'.
Construct the Pauli string representation of the identity operation.
Whether the operator is Hermitian.
Whether the operator is unitary.
"Refactor" the Pauli string by setting q to 0 and returning the corresponding overall phase factor.
"Refactor" the Pauli string by forcing q to be 0 or 1 and returning the corresponding overall sign factor.
Set a field which the Pauli string acts on (such that it can be used like a Hamiltonian).
Set an individual Pauli matrix at index i.
Attributes
Number of qubits, i.e., length of Pauli string, including identities.
- classmethod from_single_paulis(nqubits: int, *args, **kwargs)[source]¶
Construct a Pauli string from a list of single Pauli matrices, like (‘Y’, 1), (‘X’, 4), (‘Z’, 5).
- classmethod from_string(s: str)[source]¶
Construct a Pauli string from a literal string representation, like “iYZXZ”.
- classmethod identity(nqubits: int)[source]¶
Construct the Pauli string representation of the identity operation.
- property num_qubits¶
Number of qubits, i.e., length of Pauli string, including identities.
- refactor_phase()[source]¶
“Refactor” the Pauli string by setting q to 0 and returning the corresponding overall phase factor.
- refactor_sign()[source]¶
“Refactor” the Pauli string by forcing q to be 0 or 1 and returning the corresponding overall sign factor.