In numpy
, some of the operations return in shape (R, 1)
but some return (R,)
. This will make matrix multiplication more tedious since
1) The reason not to prefer a shape of (R, 1)
over (R,)
is that it unnecessarily complicates things. Besides, why would it be preferable to have shape (R, 1)
by default for a length-R vector instead of (1, R)
? It's better to keep it simple and be explicit when you require additional dimensions.
2) For your example, you are computing an outer product so you can do this without a reshape
call by using np.outer
:
np.outer(M[:,0], numpy.ones((1, R)))