I came across weird results when computing large Numpy array.
A=np.matrix('1 2 3;3 4 7;8 9 6')
A=([[1, 2, 3],
[3, 4, 7],
[8, 9, 6]])
A * A completes the dot product as expected:
A*A=([[ 31, 37, 35],
[ 71, 85, 79],
[ 83, 106, 123]])
But with a larger matrix 200X200 I get different response:
B=np.random.random_integers(0,10,(n,n))
B=array([[ 2, 0, 6, ..., 7, 3, 7],
[ 4, 9, 1, ..., 6, 7, 5],
[ 3, 1, 8, ..., 7, 3, 8],
...,
[ 8, 4, 10, ..., 5, 4, 4],
[ 6, 6, 3, ..., 7, 2, 9],
[ 2, 10, 10, ..., 5, 7, 4]])
Now multiply B with B
B*B
array([[ 4, 0, 36, ..., 49, 9, 49],
[ 16, 81, 1, ..., 36, 49, 25],
[ 9, 1, 64, ..., 49, 9, 64],
...,
[ 64, 16, 100, ..., 25, 16, 16],
[ 36, 36, 9, ..., 49, 4, 81],
[ 4, 100, 100, ..., 25, 49, 16]])
I get each element squared and not a matrix * matrix What did I do different?
Aa numpy array?