source: trunk/MATRICE/union.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

  • 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; NAME:union
6;
7; PURPOSE:calcule l''union de 2 matrices D'ENTIERS POSITIFS
8;
9; CATEGORY:calcule sur les matrices
10;
11; CALLING SEQUENCE:res=union(a,b)
12;
13; INPUTS:a et b:arrays of positive integers, which need
14;               not be sorted. Duplicate elements are ignored, as they have no
15;               effect on the result
16;
17; KEYWORD PARAMETERS:
18;
19; OUTPUTS:tableau
20;
21; COMMON BLOCKS:
22;
23; SIDE EFFECTS:
24;
25; The empty set is denoted by an array with the first element equal to
26; -1.
27;
28; RESTRICTIONS:
29;
30; These functions will not be efficient on sparse sets with wide
31; ranges, as they trade memory for efficiency. The HISTOGRAM function
32; is used, which creates arrays of size equal to the range of the
33; resulting set.
34;
35; EXAMPLE:
36;
37;   a = [2,4,6,8]
38;   b = [6,1,3,2]
39;   union(a,b) = [ 1, 2, 3, 4, 6, 8]  ; Elements in either set
40;
41; MODIFICATION HISTORY:
42;
43; http://www.dfanning.com/tips/set_operations.html
44;-
45;------------------------------------------------------------
46;------------------------------------------------------------
47;------------------------------------------------------------
48FUNCTION union, a, b
49IF a[0] LT 0 THEN RETURN, b    ;A union NULL = a
50IF b[0] LT 0 THEN RETURN, a    ;B union NULL = b
51RETURN, Where(Histogram([a,b], OMin = omin)) + omin ; Return combined set
52END
Note: See TracBrowser for help on using the repository browser.