cirq.commutes

cirq.commutes(m1: numpy.ndarray, m2: numpy.ndarray, tolerance: cirq.linalg.tolerance.Tolerance = Tolerance(rtol=1e-05, atol=1e-08, equal_nan=False)) → bool[source]

Determines if two matrices approximately commute.

Two matrices A and B commute if they are square and have the same size and
AB = BA.
Parameters:
  • m1 – One of the matrices.
  • m2 – The other matrix.
  • tolerance – The per-matrix-entry tolerance on equality.
Returns:

Whether the two matrices have compatible sizes and a commutator equal to zero within tolerance.