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

Home » Public Forums » archive » Re: VALUE_LOCATE tutorial
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: VALUE_LOCATE tutorial [message #66996] Fri, 26 June 2009 08:54
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Jun 25, 5:14 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article <ywkuk530jtjl....@snowblow.colorado.edu>, sav...@nsidc.org
> wrote:
>
>> Jeremy Bailin <astroco...@gmail.com> writes:
>
>> I think the main reason it's not used is because it's so poorly named.
>> How would you find this if you just wanted to partition some data?  I
>> can't remember who pointed it out to me first, but I do remember
>> thinking to myself, "Hmm, that's useful, wonder why I've never heard of
>> it".
>
>> Cheers,
>> Matt
>
> I think they knew that if they named it SEARCH it would conflict with
> thousands of user-written routines.  :-)
>
> Ken

Pre-5.3, I had a homebrewed version of it called BSEARCH, that I
thought was pretty efficient but which gets blown out of the water by
VALUE_LOCATE!

-Jeremy.
Re: VALUE_LOCATE tutorial [message #67012 is a reply to message #66996] Thu, 25 June 2009 16:57 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Jun 25, 7:00 pm, David Fanning <n...@dfanning.com> wrote:
> ben.bighair writes:
>> If I recall correctly, there is a function in Numerical Recipes for C
>> called locate() that does the bifurcation search on an ordered list
>> that VALUE_LOCATE does. Perhaps that is the origin of the name?
>
> If I'm not mistaken, Al Gore had the original idea for this function.
>

Hmmm. A plurality programmers thought so, too. But the software
judges overruled the will of the masses on this one, too.

Cheers,
Ben
t
P.S. I found this (http://www.nrbook.com/ub30001/nr3-3-1.pdf) but it
doesn't look like the plain old incomprehensible C that I never
figured out. Anyway, there is a routine called locate in there.
Re: VALUE_LOCATE tutorial [message #67016 is a reply to message #67012] Thu, 25 June 2009 16:00 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ben.bighair writes:

> If I recall correctly, there is a function in Numerical Recipes for C
> called locate() that does the bifurcation search on an ordered list
> that VALUE_LOCATE does. Perhaps that is the origin of the name?

If I'm not mistaken, Al Gore had the original idea for this function.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: VALUE_LOCATE tutorial [message #67017 is a reply to message #67016] Thu, 25 June 2009 15:48 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Jun 25, 5:21 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> I think VALUE_LOCATE may have come out of this discussion
>
> http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thr...
>
> back in 1998.
>
> I think I submitted an official feature request to what was then RSI, and
> in my own mind I like to take credit for VALUE_LOCATE. :-)
>
> Ken

Hi,

If I recall correctly, there is a function in Numerical Recipes for C
called locate() that does the bifurcation search on an ordered list
that VALUE_LOCATE does. Perhaps that is the origin of the name?

Cheers,
Ben
Re: VALUE_LOCATE tutorial [message #67020 is a reply to message #67017] Thu, 25 June 2009 14:21 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
I think VALUE_LOCATE may have come out of this discussion

http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thread/485e33800ea5aaf4/da3c9fd5513d8d41?lnk=gst&q =binary+search#da3c9fd5513d8d41

back in 1998.

I think I submitted an official feature request to what was then RSI, and
in my own mind I like to take credit for VALUE_LOCATE. :-)

Ken
Re: VALUE_LOCATE tutorial [message #67021 is a reply to message #67020] Thu, 25 June 2009 14:14 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <ywkuk530jtjl.fsf@snowblow.colorado.edu>, savoie@nsidc.org
wrote:

> Jeremy Bailin <astroconst@gmail.com> writes:
>
> I think the main reason it's not used is because it's so poorly named.
> How would you find this if you just wanted to partition some data? I
> can't remember who pointed it out to me first, but I do remember
> thinking to myself, "Hmm, that's useful, wonder why I've never heard of
> it".
>
> Cheers,
> Matt

I think they knew that if they named it SEARCH it would conflict with
thousands of user-written routines. :-)

Ken
Re: VALUE_LOCATE tutorial [message #67035 is a reply to message #67021] Thu, 25 June 2009 07:07 Go to previous message
Matt[2] is currently offline  Matt[2]
Messages: 69
Registered: March 2007
Member
Jeremy Bailin <astroconst@gmail.com> writes:

> There are probably two reasons why VALUE_LOCATE is underused. The
> first is that it was only introduced in IDL 5.3, well after many
> people developed their core techniques. The second is that the help
> page is somewhat opaque on what it actually does. The basic idea is
> pretty simple: given two arrays Values and Array,


I think the main reason it's not used is because it's so poorly named.
How would you find this if you just wanted to partition some data? I
can't remember who pointed it out to me first, but I do remember
thinking to myself, "Hmm, that's useful, wonder why I've never heard of
it".

Cheers,
Matt


--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
Re: VALUE_LOCATE tutorial [message #67042 is a reply to message #67035] Wed, 24 June 2009 15:20 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
There's one more important application for Value_Locate that I meant
to include!

(David - you can stick this after the "Using Ranges For Partitioning"
subsection)

- Using Ranges In An Interpolation Scheme -

Another convenient use of this property of Value_Locate is for
interpolation. Most interpolation schemes work by fitting a low-order
polynomial or similar function to the points near the desired
location. How do you efficiently determine which points are the "near
points"? Using Value_Locate!

The simplest example is a linear interpolation between the
neighbouring points: if x[i] <= array[j] <= x[i+1] (where x is
strictly increasing) then the interpolated value is:

interpolated_y[j] = y[i] * (x[i+1]-array[j])/(x[i+1]-x[i]) + y[i+1] *
(array[j]-x[i])/(x[i+1]-x[i])

The trick is to figure out which i to use for a given j... but that's
exactly what Value_Locate does! Here is some simple code that will
calculate this interpolation (I haven't taken care to handle the edge
cases correctly, but see the code of the library function Interpol for
more details):

left = Value_Locate(x, array)
right = left+1
interpolated_y = y[left] * (x[right]-array)/(x[right]-x[left]) + y
[right] * (array-x[left])/(x[right-x[left])

This is equivalent to Interpol(y, x, array).

-Jeremy.
Re: VALUE_LOCATE tutorial [message #67060 is a reply to message #67042] Wed, 24 June 2009 08:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> I've taken David's encouragement to write up this tutorial on all
> the fun uses of the insufficiently-appreciated VALUE_LOCATE
> function. ;-)

Thanks, Jeremy. Now I can go hiking this weekend! ;-)

I've prettied it up a bit and made it available on my
web page:

http://www.dfanning.com/code_tips/valuelocate.html

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: VALUE_LOCATE tutorial [message #67075 is a reply to message #67060] Wed, 24 June 2009 00:46 Go to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
Thank you for this nice tutorial!

Regards

CR
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Envi virtual machine
Next Topic: Re: IDL Help on Mac OS

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

Current Time: Wed Oct 08 15:27:38 PDT 2025

Total time taken to generate the page: 0.00788 seconds