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

Home » Public Forums » archive » Re: quick search of array
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: quick search of array [message #44570 is a reply to message #44569] Thu, 23 June 2005 12:33 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1119544592.305102.257100@g49g2000cwa.googlegroups.com>,
tanqian@hotmail.com wrote:

> Hi,
>
> I have four arraies
>
> all_time = fltarr(10000)
> all_location = fltarr(3, 10000)
>
> sel_time = fltarr(4000)
> sel_location = fltarr(3,4000)
>
> the 'sel_time' is a subset of 'all_time'. Is there a quick way I could
> find index 'j' of all_time for each sel_time(i) (when
> abs(all_time(j)-sel_time(i)) lt 1e-5)? So I could use that index to
> pick the sel_location from all_location for each sel_time(i). Since I
> have multiple(~20000) such tests, loop through both of them will be too
> time consuming.
>
> Should I sort both all_time and sel_time to descent/ascent order to
> speed it up?

If you sort your arrays, you can use VALUE_LOCATE (a binary search) instead of
WHERE (an exhaustive search). Depending on circumstances, the speed difference
can be substantial.

Ken Bowman
[Message index]
 
Read Message
Read Message
Previous Topic: quick search of array
Next Topic: Re: GeoTIFF tags and keys

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

Current Time: Tue Dec 02 06:32:33 PST 2025

Total time taken to generate the page: 2.80149 seconds