[Numpy-discussion] how to multiply the rows of a matrix by a different number?

Warren Focke focke@slac.stanford....
Tue Mar 3 20:06:50 CST 2009


M *= N[:, newaxis]

On Tue, 3 Mar 2009, Jose Borreguero wrote:

> I guess there has to be an easy way for this. I have:
> M.shape=(10000,3)
> N.shape=(10000,)
>
> I want to do this:
> for i in range(10000):
> M[i]*=N[i]
> without the explicit loop
>
>
> -Jose
>


More information about the Numpy-discussion mailing list