I have two Numpy matrices(N*N), I want to subtract them:
Matrix a
(For simplicity i just posted here a[0]
):
[ 1. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Matrix l1
(For simplicity i just posted here l1[0]
):
[ 0.99999327 0.07987602 0.03962965 0.99967095 0.12899137 0.00232801
0.9353088 0.90658779 0.99650294 0.99992827]
With this code I want to subtract them:
l1_error = a[0]-l1[0]
but i get some strange numbers as result:
[ 6.72779132e-06 -7.98760205e-02 -3.96296547e-02 -9.99670951e-01
-1.28991369e-01 -2.32801220e-03 -9.35308795e-01 -9.06587790e-01
-9.96502936e-01 -9.99928265e-01]
Why? subtracting 1.0
with 0.99999327
should give 6.72779132e-06
? I checked data type of both and both of them were float64
and ndarray
And one thing i didn't understand. When i create a random matrix, with this code:
2*np.random.random((3,1))-1
if it has one column, i get in this format:
[[-0.16595599]
[ 0.44064899]
[-0.99977125]]
But if it has several columns i get in this format:
[[-0.16595599 0.44064899 -0.99977125 -0.30887855 -0.20646505
0.07763347]
[-0.16161097 0.370439 -0.5910955 0.11737966 -0.71922612
-0.60379702]
[ 0.60148914 0.93652315 -0.37315164 -0.92189043 -0.66033916
0.75628501]]
Which there is no semicolons between items or brackets. What i'm missing here? this is related to my main problem?