SparsePauliOp

class SparsePauliOp(data, coeffs=None)[source]

Sparse N-qubit operator in a Pauli basis representation.

This is a sparse representation of an N-qubit matrix Operator in terms of N-qubit PauliTable and complex coefficients.

It can be used for performing operator arithmetic for hundred of qubits if the number of non-zero Pauli basis terms is sufficiently small.

The Pauli basis components are stored as a PauliTable object and can be accessed using the table attribute. The coefficients are stored as a complex Numpy array vector and can be accessed using the coeffs attribute.

Initialize an operator object.

Parameters
  • data (PauliTable) – Pauli table of terms.

  • coeffs (np.ndarray) – complex coefficients for Pauli terms.

Raises

QiskitError – If the input data or coeffs are invalid.

Attributes

SparsePauliOp.atol

The default absolute tolerance parameter for float comparisons.

SparsePauliOp.coeffs

Return the Pauli coefficients.

SparsePauliOp.dim

Return tuple (input_shape, output_shape).

SparsePauliOp.num_qubits

Return the number of qubits if a N-qubit operator or None otherwise.

SparsePauliOp.qargs

Return the qargs for the operator.

SparsePauliOp.rtol

The relative tolerance parameter for float comparisons.

SparsePauliOp.size

The number of Pauli of Pauli terms in the operator.

SparsePauliOp.table

Return the the PauliTable.

Methods

SparsePauliOp.__call__(qargs)

Return a clone with qargs set

SparsePauliOp.__getitem__(key)

Return a view of the SparsePauliOp.

SparsePauliOp.__len__()

Return the size.

SparsePauliOp.__mul__(other)

SparsePauliOp.add(other)

Return the linear operator self + other.

SparsePauliOp.adjoint()

Return the adjoint of the operator.

SparsePauliOp.compose(other[, qargs, front])

Return the composition channel self∘other.

SparsePauliOp.conjugate()

Return the conjugate of the operator.

SparsePauliOp.copy()

Make a deep copy of current operator.

SparsePauliOp.dot(other[, qargs])

Return the composition channel self∘other.

SparsePauliOp.expand(other)

Return the tensor product operator other ⊗ self.

SparsePauliOp.from_list(obj)

Construct from a list [(pauli_str, coeffs)]

SparsePauliOp.from_operator(obj[, atol, rtol])

Construct from an Operator objector.

SparsePauliOp.input_dims([qargs])

Return tuple of input dimension for specified subsystems.

SparsePauliOp.is_unitary([atol, rtol])

Return True if operator is a unitary matrix.

SparsePauliOp.label_iter()

Return a label representation iterator.

SparsePauliOp.matrix_iter([sparse])

Return a matrix representation iterator.

SparsePauliOp.multiply(other)

Return the linear operator other * self.

SparsePauliOp.output_dims([qargs])

Return tuple of output dimension for specified subsystems.

SparsePauliOp.power(n)

Return the compose of a operator with itself n times.

SparsePauliOp.reshape([input_dims, output_dims])

Return a shallow copy with reshaped input and output subsystem dimensions.

SparsePauliOp.set_atol(value)

Set the class default absolute tolerance parameter for float comparisons.

SparsePauliOp.set_rtol(value)

Set the class default relative tolerance parameter for float comparisons.

SparsePauliOp.simplify([atol, rtol])

Simplify PauliTable by combining duplicaties and removing zeros.

SparsePauliOp.subtract(other)

Return the linear operator self - other.

SparsePauliOp.tensor(other)

Return the tensor product operator self ⊗ other.

SparsePauliOp.to_list([array])

Convert to a list Pauli string labels and coefficients.

SparsePauliOp.to_matrix([sparse])

Convert to a dense or sparse matrix.

SparsePauliOp.to_operator()

Convert to a matrix Operator object

SparsePauliOp.transpose()

Return the transpose of the operator.

SparsePauliOp.__call__(qargs)

Return a clone with qargs set

SparsePauliOp.__mul__(other)