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

Last change on this file since 378 was 378, checked in by pinsard, 16 years ago

improvements of headers (typo, links, paragraphes, etc)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1;+
2;
3; @file_comments
4; find the union between 2 matrices of whole numbers
5;
6; see also <pro>different</pro> and <pro>inter</pro>.
7
8; @categories
9; Calculation
10;
11; @param a {in}{required}
12; 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}
17; see a
18;
19; @returns
20; an array containing the set of values in a and b.
21;
22; @restrictions
23; These functions will not be efficient on sparse sets with wide
24; ranges, as they trade memory for efficiency.
25; The <proidl>HISTOGRAM</proidl> function
26; is used, which creates arrays of size equal to the range of the
27; resulting set.
28;
29; @examples
30;
31;   IDL> a = [2,4,6,8]
32;   IDL> b = [6,1,3,2]
33;   IDL> res=union(a,b)
34;   IDL> print, res
35;           1           2           3           4           5           6
36           8
37; this is the list ao all elements in either sets.
38;
39; @history
40; <a href="http://www.dfanning.com/tips/set_operations.html"/>
41;
42; @version
43; $Id$
44;
45;-
46FUNCTION union, a, b
47;
48  compile_opt idl2, strictarrsubs
49;
50IF a[0] LT 0 THEN RETURN, b    ;A union NULL = a
51IF b[0] LT 0 THEN RETURN, a    ;B union NULL = b
52RETURN, Where(Histogram([a,b], OMin = omin)) + omin ; Return combined set
53END
Note: See TracBrowser for help on using the repository browser.