Checks if two matrices are equal.