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

Home » Public Forums » archive » Re: Using value_locate with a non-monotonic vector! And it's working!??!
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: Using value_locate with a non-monotonic vector! And it's working!??! [message #52062 is a reply to message #52054] Tue, 02 January 2007 09:12 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Gianguido Cianci wrote:
> Hi all,
>
> I am using value_locate on a unsorted vector and I am a little worried
> because the IDL manual does not really say what happens in that case. I
> would greatly appreciate your opinion and suggestions...
>
> Say I have an unsorted vector of non-unique sparsely distributed
> numbers a:
>
> a=[4.3, 4.3, 2.1, 10000,2.1]
>
> and I want to create a 1 to 1 map to a list of consecutive numbers that
> indicate ranking...
> What I do is:
>
> b=a[uniq(a,sort(a))]
> c=value_locate(b,a)
> print, c
> 1 1 0 2 0
>
> the variable c is exactly what I want in this case.
>
> The arrays I am going to deal with are much longer (10x1e6 elements) so
> i can't really check them...
>

Hi,

You are right that VALUE_LOCATE requires that the first argument be
monotonic, but the second is not subject to the same requirement. What
you have shown is that your first argument (b) is monotonic... at least
it looks right to me.

That is a pretty big array that you will be searching. You might search
a recent discussion about how efficient VALUE_LOCATE is compared to
a fixed look-up table. (I think it was Greg Michael who posted the
original question.) VALUE_LOCATE repeatedly cuts the vector (in this
case b) in half as it works to narrow down the 'width' of the search
area. That is pretty quick - but it will still have to do that for every
element in your second argument (a).

Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is ITTVIS abandoning me?
Next Topic: Re: forward slash in data item name

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

Current Time: Wed Oct 08 17:57:23 PDT 2025

Total time taken to generate the page: 0.00391 seconds