Elemental multiplication of two vectors is not a problem if they both have the same shape, say, both (n, 1) and both (n,). If one vector has the form (n, 1) and the other (n,), however, 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 elementary multiplication for a
and b
and then?
source share