a=np.arange(9).reshape([3,3])
b=np.array([10,10,10])
a
Out[16]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
b
Out[18]: array([10, 10, 10])
np.dot(a,b)
Out[22]: array([ 30, 120, 210])
np.dot(b,a)
Out[23]: array([ 90, 120, 150])
c=np.arange(6).reshape([3,2])
d=np.array([10,10,10])
c
Out[25]:
array([[0, 1],
[2, 3],
[4, 5]])
d
Out[27]: array([10, 10, 10])
np.dot(c,d)
Traceback (most recent call last):
File "<ipython-input-28-e4e1007e7d01>", line 1, in <module>
np.dot(c,d)
ValueError: shapes (3,2) and (3,) not aligned: 2 (dim 1) != 3 (dim 0)
np.dot(d,c)
Out[29]: array([60, 90])