Re: [Numpy-discussion] Multiplying Each Column of a Matrix by a Vector (Element-Wise)

2007-03-14 Thread Robert Kern
Alexander Michael wrote: > Is there a clever way to multiply each column of a matrix by a vector > *element-wise*? That is, the equivalent of (from some 1D v and 2D m): > > r = numpy.empty_like(m) > for i in range(m.shape[-1]): > r[...,i] = v*m[...,i] numpy.multiply(m, v[:,numpy.newaxis])

[Numpy-discussion] Multiplying Each Column of a Matrix by a Vector (Element-Wise)

2007-03-14 Thread Alexander Michael
Is there a clever way to multiply each column of a matrix by a vector *element-wise*? That is, the equivalent of (from some 1D v and 2D m): r = numpy.empty_like(m) for i in range(m.shape[-1]): r[...,i] = v*m[...,i] Thanks, Alex ___ Numpy-discussion