Mar-16-2019, 12:12 PM
(Mar-15-2019, 02:00 PM)mcgrim Wrote: I have kept your code and changed it a bit, however when I run it, there is a logical error in it
as I always get 1, no matter how the matrix looks.
This is because you need to use
.all()
, e.g. return (np.array(A) == np.array(A).T).all()
. Moreover, it would be better to use floating-point comparison, e.g.
np.allclose(np.array(A), np.array(A).T)
. This will allow correct handling of such cases as 0.99999999999 == 1.00000000000003, that, obviously, will return False
, but we might expect (wish) that it should return True
.