qiskit-documentation/docs/api/qiskit/0.32/qiskit.aqua.operators.legac...

29 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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: check_commutativity
description: API reference for qiskit.aqua.operators.legacy.check_commutativity
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.aqua.operators.legacy.check_commutativity
---
# qiskit.aqua.operators.legacy.check\_commutativity
<Function id="qiskit.aqua.operators.legacy.check_commutativity" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/operators/legacy/common.py" signature="check_commutativity(op_1, op_2, anti=False)">
Check the (anti-)commutativity between two operators.
**Parameters**
* **op\_1** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) operator
* **op\_2** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) operator
* **anti** (*bool*) if True, check anti-commutativity, otherwise check commutativity.
**Returns**
whether or not two operators are commuted or anti-commuted.
**Return type**
bool
</Function>