# 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

 Return a clone with qargs set Return a view of the SparsePauliOp. Return the size. SparsePauliOp.add(other) Return the linear operator self + other. Return the adjoint of the operator. SparsePauliOp.compose(other[, qargs, front]) Return the composition channel self∘other. Return the conjugate of the operator. Make a deep copy of current operator. SparsePauliOp.dot(other[, qargs]) Return the composition channel self∘other. Return the tensor product operator other ⊗ self. 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. Return a label representation iterator. SparsePauliOp.matrix_iter([sparse]) Return a matrix representation iterator. Return the linear operator other * self. SparsePauliOp.output_dims([qargs]) Return tuple of output dimension for specified subsystems. 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. Set the class default absolute tolerance parameter for float comparisons. Set the class default relative tolerance parameter for float comparisons. SparsePauliOp.simplify([atol, rtol]) Simplify PauliTable by combining duplicaties and removing zeros. Return the linear operator self - 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. Convert to a matrix Operator object Return the transpose of the operator. Return a clone with qargs set