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

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

improvements of headers (alignments)

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