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 #44569] Thu, 23 June 2005 13:21 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
<tanqian@hotmail.com> wrote in message
news:1119544592.305102.257100@g49g2000cwa.googlegroups.com.. .
> 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?
>
> Thanks,
>
> Qian
> Qian
>

How about the usual trick of expanding the 1D array to 2D arrays,
for instance:

a = all_time # (fltarr(4000)+1)

b = (fltarr(10000)+1) # sel_time

c = abs(a - b)

w = where(c lt 0.001, count)

print,count

Of course, you'll want to decode these where results into the two
dimensions,
and then take the row as the index with which to access the alltime array.

for instance, something like:

selecteddata = all_location(*,wcols)





Cheers,
bob
[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 04:21:15 PST 2025

Total time taken to generate the page: 3.36499 seconds