Or np.multiply.outer(a,b)
Nadav -----הודעה מקורית----- מאת: [email protected] בשם Robert Kern נשלח: ה 17-ספטמבר-09 00:40 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] array multiplication 2009/9/16 Ernest Adrogu? <[email protected]>: > 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 [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
<<winmail.dat>>
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
