[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
[Uni logo]


MATCH Source code in match.pro

MATCH

Name
       MATCH
Purpose
       Routine to match values in two vectors.
Calling Sequence
       match, a, b, suba, subb, [ COUNT =, /SORT ]
Input Parameters
       a,b - two vectors to match elements, numeric or string data types
Output Parameters
       suba - subscripts of elements in vector a with a match
               in vector b
       subb - subscripts of the positions of the elements in
               vector b with matchs in vector a.
       suba and subb are ordered such that a[suba] equals b[subb]
Keyword Parameters
       /SORT - By default, MATCH uses two different algorithm: (1) the
               /REVERSE_INDICES keyword to HISTOGRAM is used for integer data,
               while a sorting algorithm is used for non-integer data.   The
               histogram algorithm is usually faster, except when the input
               vectors are sparse and contain very large numbers, possibly
               causing memory problems.   Use the /SORT keyword to always use
               the sort algorithm.
Optional Keyword Output
       COUNT - set to the number of matches, integer scalar
Side Effects
       The obsolete system variable !ERR is set to the number of matches;
       however, the use !ERR is deprecated in favor of the COUNT keyword
Restrictions
       The vectors a and b should not have duplicate values within them.
       You can use rem_dup function to remove duplicate values
       in a vector
Example
       If a = [3,5,7,9,11]   & b = [5,6,7,8,9,10]
       then
               IDL> match, a, b, suba, subb, COUNT = count
       will give suba = [1,2,3], subb = [0,2,4],  COUNT = 3
       and       suba[a] = subb[b] = [5,7,9]
Procedure
       For non-integer data types, the two input vectors are combined and
       sorted and the consecutive equal elements are identified.   For integer
       data types, the /REVERSE_INDICES keyword to HISTOGRAM of each array
       is used to identify where the two arrays have elements in common.
Revision History
       D. Lindler  Mar. 1986.
       Fixed "indgen" call for very large arrays   W. Landsman  Sep 1991
       Added COUNT keyword    W. Landsman   Sep. 1992
       Fixed case where single element array supplied   W. Landsman Aug 95
       Converted to IDL V5.0   W. Landsman   September 1997
       Use a HISTOGRAM algorithm for integer vector inputs for improved
             performance                W. Landsman         March 2000
       Work again for strings           W. Landsman         April 2000
       Use size(/type)                  W. Landsman         December 2002
       Work for scalar integer input    W. Landsman         June 2003

Last modified by pro2html on 2003 June 06 at 03:56 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically