551 lines
23 KiB
Plaintext
551 lines
23 KiB
Plaintext
---
|
||
title: SparsePauliOp
|
||
description: API reference for qiskit.quantum_info.SparsePauliOp
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.quantum_info.SparsePauliOp
|
||
---
|
||
|
||
<span id="qiskit-quantum-info-sparsepauliop" />
|
||
|
||
# qiskit.quantum\_info.SparsePauliOp
|
||
|
||
<Class id="qiskit.quantum_info.SparsePauliOp" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.16/qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py" signature="SparsePauliOp(data, coeffs=None)" modifiers="class">
|
||
Sparse N-qubit operator in a Pauli basis representation.
|
||
|
||
This is a sparse representation of an N-qubit matrix [`Operator`](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator") in terms of N-qubit [`PauliTable`](qiskit.quantum_info.PauliTable "qiskit.quantum_info.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`](qiskit.quantum_info.PauliTable "qiskit.quantum_info.PauliTable") object and can be accessed using the [`table`](#qiskit.quantum_info.SparsePauliOp.table "qiskit.quantum_info.SparsePauliOp.table") attribute. The coefficients are stored as a complex Numpy array vector and can be accessed using the [`coeffs`](#qiskit.quantum_info.SparsePauliOp.coeffs "qiskit.quantum_info.SparsePauliOp.coeffs") attribute.
|
||
|
||
Initialize an operator object.
|
||
|
||
**Parameters**
|
||
|
||
* **data** ([*PauliTable*](qiskit.quantum_info.PauliTable "qiskit.quantum_info.PauliTable")) – Pauli table of terms.
|
||
* **coeffs** (*np.ndarray*) – complex coefficients for Pauli terms.
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – If the input data or coeffs are invalid.
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.__init__" signature="__init__(data, coeffs=None)">
|
||
Initialize an operator object.
|
||
|
||
**Parameters**
|
||
|
||
* **data** ([*PauliTable*](qiskit.quantum_info.PauliTable "qiskit.quantum_info.PauliTable")) – Pauli table of terms.
|
||
* **coeffs** (*np.ndarray*) – complex coefficients for Pauli terms.
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – If the input data or coeffs are invalid.
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
||
| [`__init__`](#qiskit.quantum_info.SparsePauliOp.__init__ "qiskit.quantum_info.SparsePauliOp.__init__")(data\[, coeffs]) | Initialize an operator object. |
|
||
| [`add`](#qiskit.quantum_info.SparsePauliOp.add "qiskit.quantum_info.SparsePauliOp.add")(other) | Return the linear operator self + other. |
|
||
| [`adjoint`](#qiskit.quantum_info.SparsePauliOp.adjoint "qiskit.quantum_info.SparsePauliOp.adjoint")() | Return the adjoint of the operator. |
|
||
| [`compose`](#qiskit.quantum_info.SparsePauliOp.compose "qiskit.quantum_info.SparsePauliOp.compose")(other\[, qargs, front]) | Return the composition channel self∘other. |
|
||
| [`conjugate`](#qiskit.quantum_info.SparsePauliOp.conjugate "qiskit.quantum_info.SparsePauliOp.conjugate")() | Return the conjugate of the operator. |
|
||
| [`copy`](#qiskit.quantum_info.SparsePauliOp.copy "qiskit.quantum_info.SparsePauliOp.copy")() | Make a deep copy of current operator. |
|
||
| [`dot`](#qiskit.quantum_info.SparsePauliOp.dot "qiskit.quantum_info.SparsePauliOp.dot")(other\[, qargs]) | Return the composition channel self∘other. |
|
||
| [`expand`](#qiskit.quantum_info.SparsePauliOp.expand "qiskit.quantum_info.SparsePauliOp.expand")(other) | Return the tensor product operator other ⊗ self. |
|
||
| [`from_list`](#qiskit.quantum_info.SparsePauliOp.from_list "qiskit.quantum_info.SparsePauliOp.from_list")(obj) | Construct from a list \[(pauli\_str, coeffs)] |
|
||
| [`from_operator`](#qiskit.quantum_info.SparsePauliOp.from_operator "qiskit.quantum_info.SparsePauliOp.from_operator")(obj\[, atol, rtol]) | Construct from an Operator objector. |
|
||
| [`input_dims`](#qiskit.quantum_info.SparsePauliOp.input_dims "qiskit.quantum_info.SparsePauliOp.input_dims")(\[qargs]) | Return tuple of input dimension for specified subsystems. |
|
||
| [`is_unitary`](#qiskit.quantum_info.SparsePauliOp.is_unitary "qiskit.quantum_info.SparsePauliOp.is_unitary")(\[atol, rtol]) | Return True if operator is a unitary matrix. |
|
||
| [`label_iter`](#qiskit.quantum_info.SparsePauliOp.label_iter "qiskit.quantum_info.SparsePauliOp.label_iter")() | Return a label representation iterator. |
|
||
| [`matrix_iter`](#qiskit.quantum_info.SparsePauliOp.matrix_iter "qiskit.quantum_info.SparsePauliOp.matrix_iter")(\[sparse]) | Return a matrix representation iterator. |
|
||
| [`multiply`](#qiskit.quantum_info.SparsePauliOp.multiply "qiskit.quantum_info.SparsePauliOp.multiply")(other) | Return the linear operator other \* self. |
|
||
| [`output_dims`](#qiskit.quantum_info.SparsePauliOp.output_dims "qiskit.quantum_info.SparsePauliOp.output_dims")(\[qargs]) | Return tuple of output dimension for specified subsystems. |
|
||
| [`power`](#qiskit.quantum_info.SparsePauliOp.power "qiskit.quantum_info.SparsePauliOp.power")(n) | Return the compose of a operator with itself n times. |
|
||
| [`reshape`](#qiskit.quantum_info.SparsePauliOp.reshape "qiskit.quantum_info.SparsePauliOp.reshape")(\[input\_dims, output\_dims]) | Return a shallow copy with reshaped input and output subsystem dimensions. |
|
||
| [`set_atol`](#qiskit.quantum_info.SparsePauliOp.set_atol "qiskit.quantum_info.SparsePauliOp.set_atol")(value) | Set the class default absolute tolerance parameter for float comparisons. |
|
||
| [`set_rtol`](#qiskit.quantum_info.SparsePauliOp.set_rtol "qiskit.quantum_info.SparsePauliOp.set_rtol")(value) | Set the class default relative tolerance parameter for float comparisons. |
|
||
| [`simplify`](#qiskit.quantum_info.SparsePauliOp.simplify "qiskit.quantum_info.SparsePauliOp.simplify")(\[atol, rtol]) | Simplify PauliTable by combining duplicaties and removing zeros. |
|
||
| [`subtract`](#qiskit.quantum_info.SparsePauliOp.subtract "qiskit.quantum_info.SparsePauliOp.subtract")(other) | Return the linear operator self - other. |
|
||
| [`tensor`](#qiskit.quantum_info.SparsePauliOp.tensor "qiskit.quantum_info.SparsePauliOp.tensor")(other) | Return the tensor product operator self ⊗ other. |
|
||
| [`to_list`](#qiskit.quantum_info.SparsePauliOp.to_list "qiskit.quantum_info.SparsePauliOp.to_list")(\[array]) | Convert to a list Pauli string labels and coefficients. |
|
||
| [`to_matrix`](#qiskit.quantum_info.SparsePauliOp.to_matrix "qiskit.quantum_info.SparsePauliOp.to_matrix")(\[sparse]) | Convert to a dense or sparse matrix. |
|
||
| [`to_operator`](#qiskit.quantum_info.SparsePauliOp.to_operator "qiskit.quantum_info.SparsePauliOp.to_operator")() | Convert to a matrix Operator object |
|
||
| [`transpose`](#qiskit.quantum_info.SparsePauliOp.transpose "qiskit.quantum_info.SparsePauliOp.transpose")() | Return the transpose of the operator. |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
|
||
| [`atol`](#qiskit.quantum_info.SparsePauliOp.atol "qiskit.quantum_info.SparsePauliOp.atol") | The default absolute tolerance parameter for float comparisons. |
|
||
| [`coeffs`](#qiskit.quantum_info.SparsePauliOp.coeffs "qiskit.quantum_info.SparsePauliOp.coeffs") | Return the Pauli coefficients. |
|
||
| [`dim`](#qiskit.quantum_info.SparsePauliOp.dim "qiskit.quantum_info.SparsePauliOp.dim") | Return tuple (input\_shape, output\_shape). |
|
||
| [`num_qubits`](#qiskit.quantum_info.SparsePauliOp.num_qubits "qiskit.quantum_info.SparsePauliOp.num_qubits") | Return the number of qubits if a N-qubit operator or None otherwise. |
|
||
| [`qargs`](#qiskit.quantum_info.SparsePauliOp.qargs "qiskit.quantum_info.SparsePauliOp.qargs") | Return the qargs for the operator. |
|
||
| [`rtol`](#qiskit.quantum_info.SparsePauliOp.rtol "qiskit.quantum_info.SparsePauliOp.rtol") | The relative tolerance parameter for float comparisons. |
|
||
| [`size`](#qiskit.quantum_info.SparsePauliOp.size "qiskit.quantum_info.SparsePauliOp.size") | The number of Pauli of Pauli terms in the operator. |
|
||
| [`table`](#qiskit.quantum_info.SparsePauliOp.table "qiskit.quantum_info.SparsePauliOp.table") | Return the the PauliTable. |
|
||
|
||
### add
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.add" signature="add(other)">
|
||
Return the linear operator self + other.
|
||
|
||
DEPRECATED: use `operator + other` instead.
|
||
|
||
**Parameters**
|
||
|
||
**other** (*BaseOperator*) – an operator object.
|
||
|
||
**Returns**
|
||
|
||
the operator self + other.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
</Function>
|
||
|
||
### adjoint
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.adjoint" signature="adjoint()">
|
||
Return the adjoint of the operator.
|
||
</Function>
|
||
|
||
### atol
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.atol">
|
||
The default absolute tolerance parameter for float comparisons.
|
||
</Attribute>
|
||
|
||
### coeffs
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.coeffs">
|
||
Return the Pauli coefficients.
|
||
</Attribute>
|
||
|
||
### compose
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.compose" signature="compose(other, qargs=None, front=False)">
|
||
Return the composition channel self∘other.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*SparsePauliOp*](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")) – an operator object.
|
||
* **qargs** (*list or None*) – a list of subsystem positions to compose other on.
|
||
* **front** (*bool or None*) – If False compose in standard order other(self(input)) otherwise compose in reverse order self(other(input)) \[default: False]
|
||
|
||
**Returns**
|
||
|
||
The composed operator.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
|
||
**Raises**
|
||
|
||
* **QiskitError** – if other cannot be converted to an Operator or has
|
||
* **incompatible dimensions.** –
|
||
</Function>
|
||
|
||
### conjugate
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.conjugate" signature="conjugate()">
|
||
Return the conjugate of the operator.
|
||
</Function>
|
||
|
||
### copy
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.copy" signature="copy()">
|
||
Make a deep copy of current operator.
|
||
</Function>
|
||
|
||
### dim
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.dim">
|
||
Return tuple (input\_shape, output\_shape).
|
||
</Attribute>
|
||
|
||
### dot
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.dot" signature="dot(other, qargs=None)">
|
||
Return the composition channel self∘other.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*SparsePauliOp*](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")) – an operator object.
|
||
* **qargs** (*list or None*) – a list of subsystem positions to compose other on.
|
||
|
||
**Returns**
|
||
|
||
The composed operator.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
|
||
**Raises**
|
||
|
||
* **QiskitError** – if other cannot be converted to an Operator or has
|
||
* **incompatible dimensions.** –
|
||
</Function>
|
||
|
||
### expand
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.expand" signature="expand(other)">
|
||
Return the tensor product operator other ⊗ self.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*SparsePauliOp*](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")) – an operator object.
|
||
|
||
**Returns**
|
||
|
||
the tensor product operator other ⊗ self.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a SparsePauliOp operator.
|
||
</Function>
|
||
|
||
### from\_list
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.from_list" signature="from_list(obj)" modifiers="static">
|
||
Construct from a list \[(pauli\_str, coeffs)]
|
||
</Function>
|
||
|
||
### from\_operator
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.from_operator" signature="from_operator(obj, atol=None, rtol=None)" modifiers="static">
|
||
Construct from an Operator objector.
|
||
|
||
Note that the cost of this contruction is exponential as it involves taking inner products with every element of the N-qubit Pauli basis.
|
||
|
||
**Parameters**
|
||
|
||
* **obj** ([*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – an N-qubit operator.
|
||
* **atol** (*float*) – Optional. Absolute tolerance for checking if coefficients are zero (Default: 1e-8).
|
||
* **rtol** (*float*) – Optinoal. relative tolerance for checking if coefficients are zero (Default: 1e-5).
|
||
|
||
**Returns**
|
||
|
||
the SparsePauliOp representation of the operator.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the input operator is not an N-qubit operator.
|
||
</Function>
|
||
|
||
### input\_dims
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.input_dims" signature="input_dims(qargs=None)">
|
||
Return tuple of input dimension for specified subsystems.
|
||
</Function>
|
||
|
||
### is\_unitary
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.is_unitary" signature="is_unitary(atol=None, rtol=None)">
|
||
Return True if operator is a unitary matrix.
|
||
|
||
**Parameters**
|
||
|
||
* **atol** (*float*) – Optional. Absolute tolerance for checking if coefficients are zero (Default: 1e-8).
|
||
* **rtol** (*float*) – Optinoal. relative tolerance for checking if coefficients are zero (Default: 1e-5).
|
||
|
||
**Returns**
|
||
|
||
True if the operator is unitary, False otherwise.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### label\_iter
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.label_iter" signature="label_iter()">
|
||
Return a label representation iterator.
|
||
|
||
This is a lazy iterator that converts each term in the SparsePauliOp into a tuple (label, coeff). To convert the entire table to labels use the `to_labels()` method.
|
||
|
||
**Returns**
|
||
|
||
label iterator object for the PauliTable.
|
||
|
||
**Return type**
|
||
|
||
LabelIterator
|
||
</Function>
|
||
|
||
### matrix\_iter
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.matrix_iter" signature="matrix_iter(sparse=False)">
|
||
Return a matrix representation iterator.
|
||
|
||
This is a lazy iterator that converts each term in the SparsePauliOp into a matrix as it is used. To convert to a single matrix use the [`to_matrix()`](#qiskit.quantum_info.SparsePauliOp.to_matrix "qiskit.quantum_info.SparsePauliOp.to_matrix") method.
|
||
|
||
**Parameters**
|
||
|
||
**sparse** (*bool*) – optionally return sparse CSR matrices if True, otherwise return Numpy array matrices (Default: False)
|
||
|
||
**Returns**
|
||
|
||
matrix iterator object for the PauliTable.
|
||
|
||
**Return type**
|
||
|
||
MatrixIterator
|
||
</Function>
|
||
|
||
### multiply
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.multiply" signature="multiply(other)">
|
||
Return the linear operator other \* self.
|
||
|
||
DEPRECATED: use `other * operator` instead.
|
||
|
||
**Parameters**
|
||
|
||
**other** (*complex*) – a complex number.
|
||
|
||
**Returns**
|
||
|
||
the linear operator other \* self.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
|
||
**Raises**
|
||
|
||
**NotImplementedError** – if subclass does not support multiplication.
|
||
</Function>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.num_qubits">
|
||
Return the number of qubits if a N-qubit operator or None otherwise.
|
||
</Attribute>
|
||
|
||
### output\_dims
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.output_dims" signature="output_dims(qargs=None)">
|
||
Return tuple of output dimension for specified subsystems.
|
||
</Function>
|
||
|
||
### power
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.power" signature="power(n)">
|
||
Return the compose of a operator with itself n times.
|
||
|
||
**Parameters**
|
||
|
||
**n** (*int*) – the number of times to compose with self (n>0).
|
||
|
||
**Returns**
|
||
|
||
the n-times composed operator.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the input and output dimensions of the operator are not equal, or the power is not a positive integer.
|
||
</Function>
|
||
|
||
### qargs
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.qargs">
|
||
Return the qargs for the operator.
|
||
</Attribute>
|
||
|
||
### reshape
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.reshape" signature="reshape(input_dims=None, output_dims=None)">
|
||
Return a shallow copy with reshaped input and output subsystem dimensions.
|
||
|
||
**Arg:**
|
||
|
||
**input\_dims (None or tuple): new subsystem input dimensions.**
|
||
|
||
If None the original input dims will be preserved \[Default: None].
|
||
|
||
**output\_dims (None or tuple): new subsystem output dimensions.**
|
||
|
||
If None the original output dims will be preserved \[Default: None].
|
||
|
||
**Returns**
|
||
|
||
returns self with reshaped input and output dimensions.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.
|
||
</Function>
|
||
|
||
### rtol
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.rtol">
|
||
The relative tolerance parameter for float comparisons.
|
||
</Attribute>
|
||
|
||
### set\_atol
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.set_atol" signature="set_atol(value)" modifiers="classmethod">
|
||
Set the class default absolute tolerance parameter for float comparisons.
|
||
|
||
DEPRECATED: use operator.atol = value instead
|
||
</Function>
|
||
|
||
### set\_rtol
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.set_rtol" signature="set_rtol(value)" modifiers="classmethod">
|
||
Set the class default relative tolerance parameter for float comparisons.
|
||
|
||
DEPRECATED: use operator.rtol = value instead
|
||
</Function>
|
||
|
||
### simplify
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.simplify" signature="simplify(atol=None, rtol=None)">
|
||
Simplify PauliTable by combining duplicaties and removing zeros.
|
||
|
||
**Parameters**
|
||
|
||
* **atol** (*float*) – Optional. Absolute tolerance for checking if coefficients are zero (Default: 1e-8).
|
||
* **rtol** (*float*) – Optinoal. relative tolerance for checking if coefficients are zero (Default: 1e-5).
|
||
|
||
**Returns**
|
||
|
||
the simplified SparsePauliOp operator.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
</Function>
|
||
|
||
### size
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.size">
|
||
The number of Pauli of Pauli terms in the operator.
|
||
</Attribute>
|
||
|
||
### subtract
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.subtract" signature="subtract(other)">
|
||
Return the linear operator self - other.
|
||
|
||
DEPRECATED: use `operator - other` instead.
|
||
|
||
**Parameters**
|
||
|
||
**other** (*BaseOperator*) – an operator object.
|
||
|
||
**Returns**
|
||
|
||
the operator self - other.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
</Function>
|
||
|
||
### table
|
||
|
||
<Attribute id="qiskit.quantum_info.SparsePauliOp.table">
|
||
Return the the PauliTable.
|
||
</Attribute>
|
||
|
||
### tensor
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.tensor" signature="tensor(other)">
|
||
Return the tensor product operator self ⊗ other.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*SparsePauliOp*](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")) – a operator subclass object.
|
||
|
||
**Returns**
|
||
|
||
the tensor product operator self ⊗ other.
|
||
|
||
**Return type**
|
||
|
||
[SparsePauliOp](#qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a SparsePauliOp operator.
|
||
</Function>
|
||
|
||
### to\_list
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.to_list" signature="to_list(array=False)">
|
||
Convert to a list Pauli string labels and coefficients.
|
||
|
||
For operators with a lot of terms converting using the `array=True` kwarg will be more efficient since it allocates memory for the full Numpy array of labels in advance.
|
||
|
||
**Parameters**
|
||
|
||
**array** (*bool*) – return a Numpy array if True, otherwise return a list (Default: False).
|
||
|
||
**Returns**
|
||
|
||
List of pairs (label, coeff) for rows of the PauliTable.
|
||
|
||
**Return type**
|
||
|
||
list or array
|
||
</Function>
|
||
|
||
### to\_matrix
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.to_matrix" signature="to_matrix(sparse=False)">
|
||
Convert to a dense or sparse matrix.
|
||
|
||
**Parameters**
|
||
|
||
**sparse** (*bool*) – if True return a sparse CSR matrix, otherwise return dense Numpy array (Default: False).
|
||
|
||
**Returns**
|
||
|
||
A dense matrix if sparse=False. csr\_matrix: A sparse matrix in CSR format if sparse=True.
|
||
|
||
**Return type**
|
||
|
||
array
|
||
</Function>
|
||
|
||
### to\_operator
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.to_operator" signature="to_operator()">
|
||
Convert to a matrix Operator object
|
||
</Function>
|
||
|
||
### transpose
|
||
|
||
<Function id="qiskit.quantum_info.SparsePauliOp.transpose" signature="transpose()">
|
||
Return the transpose of the operator.
|
||
</Function>
|
||
</Class>
|
||
|