qib.operator.pauli_operator.PauliOperator

class qib.operator.pauli_operator.PauliOperator(pstrings: Sequence[WeightedPauliString] | None = None)[source]

Bases: AbstractOperator

An operator consisting of Pauli strings.

Methods

add_pauli_string

Add a weighted Pauli string.

as_matrix

Generate the (sparse) matrix representation of the operator.

fields

List of fields the Pauli operator acts on.

is_hermitian

Whether the operator is Hermitian.

is_unitary

Whether the operator is unitary.

remove_zero_weight_strings

Remove the redundant Pauli strings with weight zero.

set_field

Set a field which the Pauli operator acts on (such that it can be used like a Hamiltonian).

Attributes

num_qubits

Number of qubits, i.e., length of each Pauli string, including identities.

add_pauli_string(ps: WeightedPauliString)[source]

Add a weighted Pauli string. If the string already exists, only its weight is updated.

as_matrix()[source]

Generate the (sparse) matrix representation of the operator.

fields()[source]

List of fields the Pauli operator acts on.

is_hermitian()[source]

Whether the operator is Hermitian.

is_unitary()[source]

Whether the operator is unitary.

property num_qubits

Number of qubits, i.e., length of each Pauli string, including identities.

remove_zero_weight_strings(tol=0.0)[source]

Remove the redundant Pauli strings with weight zero.

set_field(field: Field)[source]

Set a field which the Pauli operator acts on (such that it can be used like a Hamiltonian).