fastdla.SparsePauliSum

class fastdla.SparsePauliSum(indices, coeffs, num_qubits=None, dtype=np.complex128, no_check=False)

Purpose-specific implementation of a sparse Pauli operator.

SparsePauliSum is conceptually an array of ``PauliProduct``s with complex or real coefficients. Internally, the Pauli product indices and coefficients are stored separately as numpy arrays.

Parameters:
  • indices (str | int | Sequence[str] | Sequence[Sequence[int]] | Sequence[int]) – A list of parameters, each of which can initialize a PauliProduct. A single integer or str is allowed, in which case a length-1 Pauli sum is initialized.

  • coeffs (Number | Sequence[Number]) – Array of coefficients corresponding to the Pauli products specified by indices.

  • num_qubits (Optional[int]) – Required if Pauli products are specified using the compact index.

  • no_check (bool) – If True, indices is assumed to be an array of compact indices, and no formatting will be performed.

Methods

commutator(other[, normalize])

Return the commutator [self, other].

dot(other)

Return the inner product <self, other>.

from_csr(array, num_qubits)

Convert from a sparse Pauli vector in the CSR format.

normalize()

Return a normalized copy of this Pauli sum.

switch_impl(to)

Switch the implementation of operators.

to_csr()

Convert to a sparse Pauli vector in the CSR format.

to_dense()

Convert to a dense Pauli vector.

to_matrix(*[, sparse, npmod])

Convert the Pauli sum to a dense (2**num_qubits, 2**num_qubits) matrix.

Attributes

apart

Return a new SPS with anti-Hermitian terms only.

hpart

Return a new SPS with Hermitian terms only.

num_terms

Number of terms in the sum.

paulis

Return the list of PauliProducts in the string representation.

shape

Shape of the Pauli tensor.

vlen

Length of the Pauli vector.