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

Home » Public Forums » archive » Array searching efficiency
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Array searching efficiency [message #74959] Thu, 10 February 2011 15:47 Go to previous message
Matt Francis is currently offline  Matt Francis
Messages: 94
Registered: May 2010
Member
Hi All,

I'm going through and trying to squeeze every last bit of optimum
efficiency out of a code I've been working on. I have a small, very
simple, problem that I'd appreciate some experienced input on.

I have a time series of maps, but the time stamps for them are not
always regular (some maps get missed, some are late etc). I need to
(many millions of times..) find which two maps a given time sits
between, then interpolate between the relevant two maps at some given
location.

The first step is to establish, for a given time, which two maps I
need to interpolate between. I have the times for each map stored in a
single array, in time order. If I can work out the indices in that
array of the two map times then I'm done. This is a simple problem to
solve in any number of ways, but the question is which is the fastest?

I've come up with this:

iup = (WHERE(times-time_now GT 0))[0]
ilow = iup-1

I'm not sure how WHERE works 'under the hood', but assuming that at
some level it loops over the given array, then optimally once [times -
time_now] becomes positive you would stop searching. Implementing that
kind of algorithm in a WHILE loop is probably slower than using WHERE
though.

Any thoughts or suggestions?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: reading and writing very slow
Next Topic: possible bug with center keyword option for FFT

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

Current Time: Fri Oct 10 07:38:45 PDT 2025

Total time taken to generate the page: 2.07936 seconds