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

Home » Public Forums » archive » Re: Faster way ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Faster way ? [message #41172 is a reply to message #41171] Mon, 27 September 2004 13:46 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
"Craig Markwardt" <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message
news:onr7onip35.fsf@cow.physics.wisc.edu...
> rats@mail.geog.uvic.ca (Rafael Loos) writes:
>> Hi, I am trying to find the number of values that are within a range
>> ...
>> I have an Array that has 3 columns and 5 millions lines.
>> Thats what I am doing ...
>>
>> number = WHERE((Array[1,*] GE Min) AND (Array[1,*] LE Max), geralX)
>>
>> I am storing the number inside the variable geralX ...
>> It is taking 0.23 seconds ... but I want to know if there is a faster
>> way to find that ...
>
> If you are doing this many times in a loop and ARRAY is unchanging, it
> may be worth extracting ARRAY[1,*] into its own variable. That way,
> you will save the time of extracting each iteration.
>
> If you just want the total number of elements that match your filter,
> you can use total, as in:
>
> filter = (Array[1,*] GE Min) AND (Array[1,*] LE Max)
> geralX = total(filter)

Even with the two uses of Array[1,*], I got 30-40% time reduction with this:

array1 = Array[1,*]
number = WHERE((Array1 GE Min) AND (Array1 LE Max), geralX)

... and then splicing in your method gave a total of about 45% time
reduction:

array1 = Array[1,*]
geralX = Total((Array1 GE Min) AND (Array1 LE Max))

Hope this helps!

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Unique system identified?
Next Topic: IDL filled contour to PostScript - wired horizontal and vertical lines ???

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

Current Time: Wed Dec 03 14:21:37 PST 2025

Total time taken to generate the page: 0.48474 seconds