cirq.linalg.matrix_commutes

Determines if two matrices approximately commute.

Two matrices A and B commute if they are square and have the same size and AB = BA.

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.