source: trunk/SRC/Matrix/union.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
RevLine 
[2]1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
[133]6; @file_comments
[163]7; calculate the union between 2 matrices of whole numbers
[2]8;
[157]9; @categories
10; Calculation
[2]11;
[133]12; @param a {in}{required} arrays of positive integers, which need
[2]13;               not be sorted. Duplicate elements are ignored, as they have no
14;               effect on the result
15;
[133]16; @param b {in}{required} see a
[2]17;
[133]18; @returns tableau
[2]19;
[133]20; @restrictions The empty set is denoted by an array with the first element equal to
[2]21; -1.
22;
[133]23; @restrictions These functions will not be efficient on sparse sets with wide
[2]24; ranges, as they trade memory for efficiency. The HISTOGRAM function
25; is used, which creates arrays of size equal to the range of the
26; resulting set.
27;
[133]28; @examples a = [2,4,6,8]
29;           b = [6,1,3,2]
30;           union(a,b) = [ 1, 2, 3, 4, 6, 8]  ; Elements in either set
[2]31;
[133]32; @history  http://www.dfanning.com/tips/set_operations.html
[2]33;
[133]34; @version $Id$
[2]35;
36;-
37;------------------------------------------------------------
38;------------------------------------------------------------
39;------------------------------------------------------------
40FUNCTION union, a, b
[114]41;
42  compile_opt idl2, strictarrsubs
43;
[2]44IF a[0] LT 0 THEN RETURN, b    ;A union NULL = a
45IF b[0] LT 0 THEN RETURN, a    ;B union NULL = b
46RETURN, Where(Histogram([a,b], OMin = omin)) + omin ; Return combined set
47END
Note: See TracBrowser for help on using the repository browser.