Have the following:
In [14]: A = array([[1, 1], [3, 2], [-4, 1]])
In [15]: A
Out[15]:
array([[ 1, 1],
[ 3, 2],
[-4, 1]])
In [16]: x = array([1, 1])
In [17]: x
Out[17]: array([1, 1])
In [18]: dot(A, x)
Out[18]: array([ 2, 5, -3])
I was expecting a column, because dot() function is described as an ordinary matrix multiplication.
Why does it return a row instead? This behaviour seems very discouraging.
xa 1D vector, and as such has no notion of whether it’s a row vector or a column vector. Same goes for the result ofdot(A, x).Turn
xinto a 2D array, and all will be well:Finally, if you prefer to use more natural matrix notation, convert
Atonumpy.matrix: