Re: [Numpy-discussion] array multiplication

2009-09-16 Thread Nadav Horesh
Or np.multiply.outer(a,b) Nadav -הודעה מקורית- מאת: numpy-discussion-boun...@scipy.org בשם Robert Kern נשלח: ה 17-ספטמבר-09 00:40 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] array multiplication 2009/9/16 Ernest Adrogu? : > Hi, > > I have two 1-d arrays

Re: [Numpy-discussion] array multiplication

2009-09-16 Thread Robert Kern
2009/9/16 Ernest Adrogué : > 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.newaxi

[Numpy-discussion] array multiplication

2009-09-16 Thread Ernest Adrogué
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)? Thanks! -- Ernest ___ N

Re: [Numpy-discussion] array multiplication with different dtypes

2007-03-25 Thread Travis Oliphant
Jan Strube wrote: > I'm having a difficult time understanding the following behavior: > > import numpy as N > # create a new array 4 rows, 3 columns > x = N.random.random((4, 3)) > # elementwise multiplication > x*x > > newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)]) > > #

[Numpy-discussion] array multiplication with different dtypes

2007-03-25 Thread Jan Strube
I'm having a difficult time understanding the following behavior: import numpy as N # create a new array 4 rows, 3 columns x = N.random.random((4, 3)) # elementwise multiplication x*x newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)]) # interpret the array as an array of