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

Home » Public Forums » archive » Array comparison
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
Array comparison [message #32357] Tue, 01 October 2002 15:08 Go to next message
Sean Raffuse is currently offline  Sean Raffuse
Messages: 46
Registered: July 2001
Member
Hello,

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.

I know I could do this in a loop, but I need the speed and I'm sure IDL can
do this in one line. I'm just not sure how.

Thanks,

Sean Raffuse
Re: Array Comparison [message #49462 is a reply to message #32357] Wed, 26 July 2006 08:42 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
ChristopherFlorio@gmail.com writes:
> I am looking for a simple comparison tool such with an array of
> consecutive numbers (i.e. [0,1,2,3,4,5,6,7,8,9]) and array of numbers
> included in that array (i.e. [0,5,9]) I can calculate the matrix of
> "left-over" items (i.e [1,2,3,4,6,7,8]). This can be either array of
> integers or strings. Any Suggestions?

You could use my set manipulator. For example, in your A AND NOT(B)
case,

IDL> a = [0,1,2,3,4,5,6,7,8,9]
IDL> b = [0,5,9]
IDL> print, cmset_op(a, 'AND', /NOT2, b)
1 2 3 4 6 7 8
or
IDL> print, cmset_op(a, 'XOR', b)
1 2 3 4 6 7 8

Hope that helps!
Craig

P.S. Please see http://cow.physics.wisc.edu/~craigm/idl/ under "Array/Set"

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL_IDLBridge in Virtual Machine
Next Topic: Re: Deleting a variable from a NetCDF file

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

Current Time: Wed Oct 08 14:55:56 PDT 2025

Total time taken to generate the page: 0.00421 seconds