First as always we must import numpy
:
import numpy as np
Let's create ourselves an array as before and change their shape.
a = np.arange(10).reshape( (2,5) )
b = np.arange(10).reshape( (2,5) )
print(a)
Now we can begin to use numpy
in 'happiness', ie use it to make our lives easier
c=0.1*a
print(c)
Now is c
a copy of the original array or just a new view?
c[(0,0)] = -1
print(a)
print(c)
c.base is a
Now that we have operated on a single array let's multiply to arrays together
print(a*b)
If we want to perform a well defined operation such as a dot product then we need to construct this properly, for two (non-square) arrays of the same shape, the dot product is defined if:
$a \cdot b^T$
We can perform this using numpy
with:
print(a.dot(b.T))