# cirq.commutes¶

cirq.commutes(m1: numpy.ndarray, m2: numpy.ndarray, *, rtol: float = 1e-05, atol: float = 1e-08) → 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. rtol – The per-matrix-entry relative tolerance on equality. atol – The per-matrix-entry absolute tolerance on equality. Whether the two matrices have compatible sizes and a commutator equal to zero within tolerance.