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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Using value_locate with a non-monotonic vector! And it's working!??! [message #52054] Wed, 03 January 2007 18:23
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
Hi Ben,

you are absolutely right: I just did not read the manual carefully
enough :-( Sorry everyone...

Also, I will look into fixed look-up tables! thanks for the advice!

Gianguido


Ben Tupper wrote:
> 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
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 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
Re: Using value_locate with a non-monotonic vector! And it's working!??! [message #52072 is a reply to message #52062] Sun, 31 December 2006 17:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gianguido Cianci writes:

> As sometimes happens when the Coyote speaks, I am having trouble
> discerning between whether I should worry about the RSI/ITTVIS folk
> knowing some folks who could 'get to me' if I misuse their code ;-) or
> whether I should worry because my code might explode in my face...
>
> Anybody know which is more likely?

Let me put it this way. If I were going near an unsorted
vector with VALUE_LOCATE, I would be SURE I was wearing
my safety goggles and heavy gloves. :-)

Happy New Year!!

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: Using value_locate with a non-monotonic vector! And it's working!??! [message #52073 is a reply to message #52072] Sun, 31 December 2006 15:07 Go to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
> I think you are right to worry. I'd be VERY worried. :-)


As sometimes happens when the Coyote speaks, I am having trouble
discerning between whether I should worry about the RSI/ITTVIS folk
knowing some folks who could 'get to me' if I misuse their code ;-) or
whether I should worry because my code might explode in my face...

Anybody know which is more likely?

Gianguido
Re: Using value_locate with a non-monotonic vector! And it's working!??! [message #52075 is a reply to message #52073] Sun, 31 December 2006 06:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gianguido Cianci writes:

> I am just worried that by not using value_locate as the RSI/ITTVIS
> people intended I might be getting my self into trouble.
>
> Any advice?

I think you are right to worry. I'd be VERY worried. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
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 13:46:59 PDT 2025

Total time taken to generate the page: 0.00728 seconds