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

Home » Public Forums » archive » Vector comparison.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Vector comparison. [message #37134] Wed, 19 November 2003 11:38
hunter is currently offline  hunter
Messages: 9
Registered: June 2003
Junior Member
Hello,

These seems to be a fairly simple problem but I'm having difficulty coming
up with an elegant solution.

Let's say I have two vectors of type integer:

A=[0,1,3,3,3,6,7,9,9]
B=[3,7]

I would like to design a function which returns the indices of all the
elements of A which appear in B.

i.e.

C=get_match(A,B)

should return

C=[2,3,4,6]

The simplest answer (I believe) is to loop through B and use the where
command. I just wonder if there is a way to do this without useing the loop,
as (in reality) the length of B may be very large.

I suppose another possibility is to use the histogram command with
reverse_indices set. But I think this would still require me to use a loop.
Although it may be faster since I would only have to call histogram once.
Any thoughts?

Thanks,
Eli
[Message index]
 
Read Message
Previous Topic: SAV file generation with command line arguments
Next Topic: Access GOES McIDAS files?

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

Current Time: Thu Oct 09 06:50:01 PDT 2025

Total time taken to generate the page: 0.56094 seconds