Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Stéfan van der Walt
2009/4/30 David Warde-Farley : > Have you considered coding up a looped version in Cython? If this is > going to be a bottleneck then it would be very worthwhile. Stéfan's > code is clever, although as he points out, it will create an > intermediate array of size (len(I))**2, which may end up being

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
David Warde-Farley wrote: > On 29-Apr-09, at 5:49 PM, Dan Goodman wrote: > >> Thanks David, that's nice but unfortunately that Python loop will kill >> me. I'm thinking about some simulation code I'm writing where this >> operation will be carried out many, many times, with large arrays I. I >> fi

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
Stéfan van der Walt wrote: > 2009/4/29 Dan Goodman : >> Here's the problem I want to write vectorised code for. I start with an >> array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up >> with an array C that counts how many times each index has been seen so >> far if you were count

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread David Warde-Farley
On 29-Apr-09, at 5:49 PM, Dan Goodman wrote: > Thanks David, that's nice but unfortunately that Python loop will kill > me. I'm thinking about some simulation code I'm writing where this > operation will be carried out many, many times, with large arrays I. I > figure I need to keep the Python ove

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
David Warde-Farley wrote: > On 29-Apr-09, at 5:06 PM, Dan Goodman wrote: > >> Here's the problem I want to write vectorised code for. I start with >> an >> array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up >> with an array C that counts how many times each index has been seen

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Stéfan van der Walt
2009/4/29 Dan Goodman : > Here's the problem I want to write vectorised code for. I start with an > array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up > with an array C that counts how many times each index has been seen so > far if you were counting through the array from the be

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread David Warde-Farley
On 29-Apr-09, at 5:06 PM, Dan Goodman wrote: > Here's the problem I want to write vectorised code for. I start with > an > array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up > with an array C that counts how many times each index has been seen so > far if you were counting th

[Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
Hi all, Here's the problem I want to write vectorised code for. I start with an array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up with an array C that counts how many times each index has been seen so far if you were counting through the array from the beginning to the end,