qiskit-documentation/docs/api/qiskit/0.26/qiskit.aqua.operators.conve...

79 lines
4.7 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: AbelianGrouper
description: API reference for qiskit.aqua.operators.converters.AbelianGrouper
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.aqua.operators.converters.AbelianGrouper
---
# qiskit.aqua.operators.converters.AbelianGrouper
<Class id="qiskit.aqua.operators.converters.AbelianGrouper" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/operators/converters/abelian_grouper.py" signature="AbelianGrouper(traverse=True)" modifiers="class">
The AbelianGrouper converts SummedOps into a sum of Abelian sums.
Meaning, it will traverse the Operator, and when it finds a SummedOp, it will evaluate which of the summed sub-Operators commute with one another. It will then convert each of the groups of commuting Operators into their own SummedOps, and return the sum-of-commuting-SummedOps. This is particularly useful for cases where mutually commuting groups can be handled similarly, as in the case of Pauli Expectations, where commuting Paulis have the same diagonalizing circuit rotation, or Pauli Evolutions, where commuting Paulis can be diagonalized together.
**Parameters**
**traverse** (`bool`) Whether to convert only the Operator passed to `convert`, or traverse down that Operator.
### \_\_init\_\_
<Function id="qiskit.aqua.operators.converters.AbelianGrouper.__init__" signature="__init__(traverse=True)">
**Parameters**
**traverse** (`bool`) Whether to convert only the Operator passed to `convert`, or traverse down that Operator.
</Function>
## Methods
| | |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.aqua.operators.converters.AbelianGrouper.__init__ "qiskit.aqua.operators.converters.AbelianGrouper.__init__")(\[traverse]) | **type traverse**`bool` |
| [`convert`](#qiskit.aqua.operators.converters.AbelianGrouper.convert "qiskit.aqua.operators.converters.AbelianGrouper.convert")(operator) | Check if operator is a SummedOp, in which case covert it into a sum of mutually commuting sums, or if the Operator contains sub-Operators and `traverse` is True, attempt to convert any sub-Operators. |
| [`group_subops`](#qiskit.aqua.operators.converters.AbelianGrouper.group_subops "qiskit.aqua.operators.converters.AbelianGrouper.group_subops")(list\_op\[, fast, use\_nx]) | Given a ListOp, attempt to group into Abelian ListOps of the same type. |
### convert
<Function id="qiskit.aqua.operators.converters.AbelianGrouper.convert" signature="convert(operator)">
Check if operator is a SummedOp, in which case covert it into a sum of mutually commuting sums, or if the Operator contains sub-Operators and `traverse` is True, attempt to convert any sub-Operators.
**Parameters**
**operator** (`OperatorBase`) The Operator to attempt to convert.
**Return type**
`OperatorBase`
**Returns**
The converted Operator.
</Function>
### group\_subops
<Function id="qiskit.aqua.operators.converters.AbelianGrouper.group_subops" signature="group_subops(list_op, fast=None, use_nx=None)" modifiers="classmethod">
Given a ListOp, attempt to group into Abelian ListOps of the same type.
**Parameters**
* **list\_op** (`ListOp`) The Operator to group into Abelian groups
* **fast** (`Optional`\[`bool`]) Ignored - parameter will be removed in future release
* **use\_nx** (`Optional`\[`bool`]) Ignored - parameter will be removed in future release
**Return type**
`ListOp`
**Returns**
The grouped Operator.
**Raises**
[**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") If any of list\_ops sub-ops is not `PauliOp`.
</Function>
</Class>