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

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

english and nicer header (1)

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