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
RevLine 
[2]1;+
2;
[231]3; @file_comments
[373]4; find the union between 2 matrices of whole numbers
[2]5;
[378]6; see also <pro>different</pro> and <pro>inter</pro>.
[373]7
[231]8; @categories
[157]9; Calculation
[2]10;
[231]11; @param a {in}{required}
12; arrays of positive integers, which need
[372]13; not be sorted. Duplicate elements are ignored, as they have no
14; effect on the result
[2]15;
[237]16; @param b {in}{required}
17; see a
[2]18;
[231]19; @returns
[373]20; an array containing the set of values in a and b.
[2]21;
[237]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
[2]26; is used, which creates arrays of size equal to the range of the
27; resulting set.
28;
[231]29; @examples
[2]30;
[371]31;   IDL> a = [2,4,6,8]
32;   IDL> b = [6,1,3,2]
[373]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.
[371]38;
[231]39; @history
[232]40; <a href="http://www.dfanning.com/tips/set_operations.html"/>
[2]41;
[231]42; @version
43; $Id$
[2]44;
45;-
46FUNCTION union, a, b
[114]47;
48  compile_opt idl2, strictarrsubs
49;
[2]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.