cirq.SupportsCommutes

An object that can determine commutation relationships vs others.

Methods

_commutes_

View source

Determines if this object commutes with the other object.

Can return None to indicate the commutation relationship is indeterminate (e.g. incompatible matrix sizes). Can return NotImplemented to indicate to the caller that they should try some other way of determining the commutation relationship.

Args
other The other object that may or may not commute with the receiving object.
atol Absolute error tolerance. Some objects that commute may appear to not quite commute, due to rounding error from floating point computations. This parameter indicates an acceptable level of deviation from exact commutativity. The exact meaning of what error is being tolerated is not specified. It could be the maximum angle between rotation axes in the Bloch sphere, or the maximum trace of the absolute value of the commutator, or some other value convenient to the implementor of the method.

Returns
Whether or not the values commute.
True self commutes with other within absolute tolerance atol.
False self does not commute with other.
None There is not a well defined commutation result. For example, whether or not parameterized operations will commute may depend on the parameter values and so is indeterminate.
NotImplemented Unable to determine anything about commutativity. Consider falling back to other strategies, such as asking other if it commutes with self or computing the unitary matrices of both values.