[Numpy-discussion] array multiplication
Nadav Horesh
nadavh at visionsense.com
Thu Sep 17 01:39:52 EDT 2009
Or
np.multiply.outer(a,b)
Nadav
-----הודעה מקורית-----
מאת: numpy-discussion-bounces at scipy.org בשם Robert Kern
נשלח: ה 17-ספטמבר-09 00:40
אל: Discussion of Numerical Python
נושא: Re: [Numpy-discussion] array multiplication
2009/9/16 Ernest Adrogu? <eadrogue at gmx.net>:
> Hi,
>
> I have two 1-d arrays (a and b), and I want to create a
> third 2-d array, whose rows are of the form a[i]*b:
>
> c = np.zeros((len(a),b))
>
> c[0] = a[0]*b
> c[1] = a[1]*b
> .
> .
> .
>
> Is there an easy way to do this (e.g, without a loop)?
c = a[:,np.newaxis] * b
http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion at scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090917/4065af9d/attachment.bin>
More information about the NumPy-Discussion
mailing list