Assume we want to compute the dot product of a matrix and a column vector:
So in Numpy/Python here we go:
a=numpy.asarray([[1,2,3], [4,5,6], [7,8,9]])
b=numpy.asarray([[2],[1],[3]])
a.dot(b)
Results in:
array([[13], [31], [49]])
So far, so good, however why is this also working?
b=numpy.asarray([2,1,3])
a.dot(b)
Results in:
array([13, 31, 49])
I would expect that [2,1,3] is a row vector (which requires a transpose to apply the dot product), but Numpy seems to see arrays by default as column vectors (in case of matrix multiplication)?
How does this work?
EDIT:
And why is:
b=numpy.asarray([2,1,3])
b.transpose()==b
So the matrix dot vector array does work (so then it sees it as a column vector), however other operations (transpose) does not work. This is not really consistent design isn't it?