[Numpy-discussion] Indexing a 2-d array with a 1-d mask

2011-02-08 Thread Alok Singhal
Hi, I have an NxM array, which I am indexing with a 1-d, length N boolean array. For example, with a 3x5 array: In [1]: import numpy In [2]: data = numpy.arange(15) In [3]: data.shape = 3, 5 Now, I want to select rows 0 and 2, so I can do: In [4]: mask = numpy.array([True, False, True]) In [5]

Re: [Numpy-discussion] Permission to close ticket for Mark Wiebe

2011-02-08 Thread Pauli Virtanen
Tue, 08 Feb 2011 11:35:12 -0700, Charles R Harris wrote: > Permission to close ticket for Mark Wiebe > > I don't know who handles these permissions, I didn't see a way to do it > myself. Granted. (You'd need a shell account to do these changes.) -- Pauli Virtanen ___

[Numpy-discussion] Permission to close ticket for Mark Wiebe

2011-02-08 Thread Charles R Harris
I don't know who handles these permissions, I didn't see a way to do it myself. Chuck ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Ben Gamari
On Tue, 08 Feb 2011 18:06:48 +, Andrew Jaffe wrote: > For this shape=(N,3) vector, this is not what you mean: as Robert Kern > also has it you want axis=1, which produces a shape=(N,) (or the > [:,newaxis] version which produces shape=(N,1). > > But what is the point of the ones(3)? I think

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Andrew Jaffe
On 08/02/2011 16:44, Ben Gamari wrote: > I have an array of (say, row) vectors, > >v = [ [ a1, a2, a3 ], > [ b1, b2, b3 ], > [ c1, c2, c3 ], > ... >] > > What is the optimal way to compute the norm of each vector, >norm(v)**2 = [ >[ a1**2 + a2**2 +

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Robert Kern
On Tue, Feb 8, 2011 at 11:55, Ben Gamari wrote: > On Tue, 8 Feb 2011 10:46:34 -0600, Robert Kern wrote: >> (v*v).sum(axis=1)[:,np.newaxis] >> >> You can leave off the newaxis bit if you don't really need a column vector. >> > Fair enough, I unfortunately neglected to mention that I ultimately wan

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Ben Gamari
On Tue, 8 Feb 2011 10:46:34 -0600, Robert Kern wrote: > (v*v).sum(axis=1)[:,np.newaxis] > > You can leave off the newaxis bit if you don't really need a column vector. > Fair enough, I unfortunately neglected to mention that I ultimately want to normalize these vectors, hence the *ones(3) in my

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Robert Kern
On Tue, Feb 8, 2011 at 10:44, Ben Gamari wrote: > I have an array of (say, row) vectors, > >  v = [ [ a1, a2, a3 ], >        [ b1, b2, b3 ], >        [ c1, c2, c3 ], >        ... >      ] > > What is the optimal way to compute the norm of each vector, >  norm(v)**2 = [ >      [ a1**2 + a2**2 + a3*

[Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Ben Gamari
I have an array of (say, row) vectors, v = [ [ a1, a2, a3 ], [ b1, b2, b3 ], [ c1, c2, c3 ], ... ] What is the optimal way to compute the norm of each vector, norm(v)**2 = [ [ a1**2 + a2**2 + a3**2 ], [ b1**2 + b2**2 + b3**2 ], ... ] It see

Re: [Numpy-discussion] Need a good idea: calculate the mean of many vectors

2011-02-08 Thread Pauli Virtanen
Tue, 08 Feb 2011 15:24:10 +, EMMEL Thomas wrote: [clip] > n = 100 # for test otherwise ~30 > a1 = reshape(zeros(3*n).astype(float), (n,3)) > > a2 = zeros(n).astype(int) > > for indices, data in [...]: > #data = array((1.,2.,3.)) > #indices = (1,5,60) > for index in indices: >

Re: [Numpy-discussion] Need a good idea: calculate the mean of many vectors

2011-02-08 Thread Robert Kern
On Tue, Feb 8, 2011 at 09:24, EMMEL Thomas wrote: > Hi, > > here is something I am thinking about for some time and I am wondering > whether there is a better solution > within numpy. > > The task is: > I have an array (30+ entries) with arrays each with length == 3, that is > initially empty

[Numpy-discussion] Need a good idea: calculate the mean of many vectors

2011-02-08 Thread EMMEL Thomas
Hi, here is something I am thinking about for some time and I am wondering whether there is a better solution within numpy. The task is: I have an array (30+ entries) with arrays each with length == 3, that is initially empty like this: n = 100 # for test otherwise ~30 a1 = reshape(zer