qiskit.quantum_info.SparsePauliOp.group_commuting¶
- SparsePauliOp.group_commuting(qubit_wise=False)[Quellcode]¶
Partition a SparsePauliOp into sets of commuting Pauli strings.
- Parameter
qubit_wise (bool) –
whether the commutation rule is applied to the whole operator, or on a per-qubit basis. For example:
>>> op = SparsePauliOp.from_list([("XX", 2), ("YY", 1), ("IZ",2j), ("ZZ",1j)]) >>> op.group_commuting() [SparsePauliOp(["IZ", "ZZ"], coeffs=[0.+2.j, 0.+1j]), SparsePauliOp(["XX", "YY"], coeffs=[2.+0.j, 1.+0.j])] >>> op.group_commuting(qubit_wise=True) [SparsePauliOp(['XX'], coeffs=[2.+0.j]), SparsePauliOp(['YY'], coeffs=[1.+0.j]), SparsePauliOp(['IZ', 'ZZ'], coeffs=[0.+2.j, 0.+1.j])]
- Rückgabe
- List of SparsePauliOp where each SparsePauliOp contains
commuting Pauli operators.
- Rückgabetyp
List[SparsePauliOp]