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

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

header improvements + xxx doc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; calculate tne union between 2 matrixes of whole numbers
8;
9; @categories
10; Calculation
11;
12; @param a {in}{required} arrays of positive integers, which need
13;               not be sorted. Duplicate elements are ignored, as they have no
14;               effect on the result
15;
16; @param b {in}{required} see a
17;
18; @returns tableau
19;
20; @restrictions The empty set is denoted by an array with the first element equal to
21; -1.
22;
23; @restrictions These functions will not be efficient on sparse sets with wide
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;
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
31;
32; @history  http://www.dfanning.com/tips/set_operations.html
33;
34; @version $Id$
35;
36;-
37;------------------------------------------------------------
38;------------------------------------------------------------
39;------------------------------------------------------------
40FUNCTION union, a, b
41;
42  compile_opt idl2, strictarrsubs
43;
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.