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

Home » Public Forums » archive » Re: Array 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
Re: Array comparison [message #32352 is a reply to message #32351] Tue, 01 October 2002 19:59 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Sean Raffuse" <sean@me.wustl.edu> writes:

> I would like to compare two arrays of different size. What I want to know
> is if the two arrays share ANY of the same values, regardless of index.
>
> e.g.
>
> Array1 = [1,2,3,4,5]
> Array2 = [5,6,7]
>
> Comparing these two arrays should return true because they both have the
> value 5.

Mike has a nice one-off comparison you can use. For your kinds of
set-comparison tests, I use CMSET_OP with an intersection test.

intersection = cmset_op(array1, 'AND', array2, count=ct)
if ct GT 0 then print, 'Arrays match'

The variable INTERSECTION contains the intersection between the two
sets. The internals of CMSET_OP are ultimately the same as Mike's
approach, but with a bit more flexibility.

Craig

http://cow.physics.wisc.edu/~craigm/idl/idl.html

--
------------------------------------------------------------ --------------
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
Read Message
Read Message
Read Message
Read Message
Previous Topic: Looking for more ideas on code ...
Next Topic: Re: ROI application...

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

Current Time: Fri Oct 10 10:33:52 PDT 2025

Total time taken to generate the page: 0.31966 seconds