fastdla.SparsePauliSum
- class fastdla.SparsePauliSum(indices, coeffs, num_qubits=None, no_check=False)
Purpose-specific implementation of a sparse Pauli operator.
SparsePauliSumis conceptually an array of ``PauliProduct``s with complex 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 byindices.num_qubits (
Optional[int]) – Required if Pauli products are specified using the compact index.no_check (
bool) – If True,indicesis 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.
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
apartReturn a new SPS with anti-Hermitian terms only.
hpartReturn a new SPS with Hermitian terms only.
num_termsNumber of terms in the sum.
paulisReturn the list of PauliProducts in the string representation.
shapeShape of the Pauli tensor.
vlenLength of the Pauli vector.