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

Home » Public Forums » archive » how to get index of array B data in array A
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: how to get index of array B data in array A [message #14653 is a reply to message #14613] Mon, 15 March 1999 00:00 Go to previous message
Hermann Mannstein is currently offline  Hermann Mannstein
Messages: 22
Registered: September 1995
Junior Member
Gary Fu wrote:
>
> David,
>
> Thanks for your quick response. Is there any other methods without
> using
> the FOR loop, since my A and B array may have more than 250000 elements
> ?
>
> Thanks.
>
> Gary
>>
>> Gary Fu (gfu@seadas.gsfc.nasa.gov) writes:
>>
>>> Is there a simple way to get the index of the array B data in array A ?
>>>
>>> For example : A = [10,20,30,40,50], B = [10, 20, 33, 10, 30, 40, 9]
>>> I want like to get the index array of B in A [0, 1, -1, 0, 2, 3, -1]


If the values in A are confined to a reasonable range, you could do the
following:

a_index = indgen(n_elements(a)) ; the array with the index numbers
c= lonarr(max(a) + 1) - 1 ; some kind of a look-up table,
initialize to -1
c(a) = a_index ; set every value to it's index number

index_a_in_b = c(b < max(a))

With negative numbers in a you will have add the min(a) to both,
A and B
-
Regards,

------------------------------------------------------------ ----
Dr. Hermann Mannstein
/|
DLR-Institut fuer Physik der Atmosphaere / |
Oberpfaffenhofen ,---/--|---,
D-82234 Wessling / / / /
Germany '---|--/---'
| /
tel.: +49-8153-28-2503 |/ DLR
fax.: +49-8153-28-1841 '
mailto:Hermann.Mannstein@dlr.de
http://www.op.dlr.de/ipa/ http://www.op.dlr.de/~pa64
------------------------------------------------------------ ----
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Maximum memory under Windows NT
Next Topic: Re: working with very large data sets

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

Current Time: Sat Oct 11 10:30:00 PDT 2025

Total time taken to generate the page: 3.59810 seconds