I tried to create a random symmetric matrix to test my program. I don’t care at all about the data as long as it is symmetrical (enough randomness does not cause any concern).
My first attempt:
x=np.random.random((100,100))
x+=x.T
However, np.all(x==x.T)returns False. print x==x.Tgives
array([[ True, True, True, ..., False, False, False],
[ True, True, True, ..., False, False, False],
[ True, True, True, ..., False, False, False],
...,
[False, False, False, ..., True, True, True],
[False, False, False, ..., True, True, True],
[False, False, False, ..., True, True, True]], dtype=bool)
I tried to run a small test case with n = 10 to see what happens, but this example works just as you expected.
If I do it like this:
x=np.random.random((100,100))
x=x+x.T
then it works great.
What's going on here? Are these statements semantically equivalent? Who cares?