Elementwise multiplication of two vectors is no problem if they both have the same shape, say both (n,1) or both (n,). If one vector has shape (n,1) and the other (n,), though, the *
-operator returns something funny.
a = np.ones((3,1))
b = np.ones((3,))
print a * b
The resulting nxn-matrix contains A_{i,j}=a_i*b_j.
How can I do elementwise multiplication for the a
and b
then?