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

Home » Public Forums » archive » Finding values in an 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: Finding values in an array [message #25574 is a reply to message #25476] Sun, 24 June 2001 23:18 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Bob Fugate <rqfugate@mindspring.com> writes:

> I have a vector containing a very, very large number of long integer values.
>
> I want to compare the value of each element in the vector to the values of
> the elements in the first column of a two column array until there is a
> match, and then extract the corresponding number in the second column (e.g.
> by using WHERE) of the array.
>
> Does anyone know a way to do this without using a loop? I realise that
> organizing the searched array as two rows may speed this up, however, I am
> trying to avoid using a loop. The numbers in the vector vary randomly (and
> it is important to preserve the original order) but the numbers in the first
> column of the array are sorted and increase monotonically (if that matters).
>
> I am new to IDL, so will greatly appreciate any suggestions.

If you can guarantee that there won't be any "misses", ie all
possibilities are in your second table, then VALUE_LOCATE is your
friend. This is new in IDL 5.3, but presumably you have at least this
version. If not, then see my web page for a drop-in substitute. :-)

You are basically done then!

wh = value_locate(col1, vector)
y = col2(wh)

Cogitate on that for awhile and I think you will be satisfied.
Good luck,
Craig

Web page: http://cow.physics.wisc.edu/~craigm/idl/idl.html (Main listing)

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: template for READ_ASCII
Next Topic: Re: pickdata and select again....

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

Current Time: Wed Oct 08 18:38:21 PDT 2025

Total time taken to generate the page: 0.00555 seconds