comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: uniq slow for loop
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: uniq slow for loop [message #67263] Fri, 17 July 2009 08:59
newerjazz is currently offline  newerjazz
Messages: 5
Registered: July 2009
Junior Member
Thanks Ben


I rewrote using histogram so as to eliminate calling where inside for
loop. Program is running now. Am sire it will be faster. Any comments
on how to improve further is appreciated.

h=histogram(data(8,*),binsize=1)
hmax=size(h)
hmax=hmax(1)-1

FOR j=0, hmax DO BEGIN
blah=mean(data(*,i:i+h(j)-1))
etc,etc
i=h(j)+i
ENDFOR


On Jul 16, 6:40 pm, "ben.bighair" <ben.bigh...@gmail.com> wrote:
> On Jul 16, 5:52 pm, newerjazz <shang...@gmail.com> wrote:
>
>
>
>> Hi All,
>
>> I have an array of [9,1,000,000]. In one of the columns are sorted
>> numbers (eg. 0,1,1,2,3,3,3,3,3,4,4,5,5,5,6,7,7,7,etc). I want to pick
>> out all the rows where column 9 is equal to some number and average
>> all the quantities in those rows.
>
>> Right now I use a for loop and the where function to pick out these
>> rows. This is of course very slow. Anyway to increase the speed of
>> this would be greatly appreciated. Thank you very much!
>
>> Cheers,
>> newerjazz
>
>> nmax = max(data(8,*))
>> FOR  j=0, nmax DO BEGIN
>>   w=where(data(8,*) eq j, nw)
>>   blah=mean(data(*,w))
>>   etc,etc
>> ENDFOR
>
> Hi,
>
> I am pretty sure that you want a variant of histogram.  I think you
> might be able to harness something from the following discussion.
>
> http://tinyurl.com/nggcx6
>
> Cheers,
> Ben
Re: uniq slow for loop [message #67269 is a reply to message #67263] Thu, 16 July 2009 18:40 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Jul 16, 5:52 pm, newerjazz <shang...@gmail.com> wrote:
> Hi All,
>
> I have an array of [9,1,000,000]. In one of the columns are sorted
> numbers (eg. 0,1,1,2,3,3,3,3,3,4,4,5,5,5,6,7,7,7,etc). I want to pick
> out all the rows where column 9 is equal to some number and average
> all the quantities in those rows.
>
> Right now I use a for loop and the where function to pick out these
> rows. This is of course very slow. Anyway to increase the speed of
> this would be greatly appreciated. Thank you very much!
>
> Cheers,
> newerjazz
>
> nmax = max(data(8,*))
> FOR j=0, nmax DO BEGIN
> w=where(data(8,*) eq j, nw)
> blah=mean(data(*,w))
> etc,etc
> ENDFOR

Hi,

I am pretty sure that you want a variant of histogram. I think you
might be able to harness something from the following discussion.

http://tinyurl.com/nggcx6

Cheers,
Ben
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: projections in idl
Next Topic: shapeinfo

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:17:12 PDT 2025

Total time taken to generate the page: 0.00573 seconds