qml.liealg.check_abelian

check_abelian(ops)[source]

Helper function to check if all operators in ops commute, i.e., form an Abelian set of operators.

Warning

This function is expensive to compute

Parameters

ops (List[Union[PauliSentence, TensorLike, Operator]]) – List of operators to check for mutual commutation

Returns

Whether or not all operators commute with each other

Return type

bool

Example

>>> from pennylane.liealg import check_abelian
>>> from pennylane import X
>>> ops = [X(i) for i in range(10)]
>>> check_abelian(ops)
True

Operators on different wires (trivially) commute with each other.