;+ ; ; @file_comments ; find the union between 2 matrices of whole numbers ; ; see also different and inter. ; @categories ; Calculation ; ; @param a {in}{required} ; arrays of positive integers, which need ; not be sorted. Duplicate elements are ignored, as they have no ; effect on the result ; ; @param b {in}{required} ; see a ; ; @returns ; an array containing the set of values in a and b. ; ; @restrictions ; These functions will not be efficient on sparse sets with wide ; ranges, as they trade memory for efficiency. ; The HISTOGRAM function ; is used, which creates arrays of size equal to the range of the ; resulting set. ; ; @examples ; ; IDL> a = [2,4,6,8] ; IDL> b = [6,1,3,2] ; IDL> res=union(a,b) ; IDL> print, res ; 1 2 3 4 5 6 8 ; this is the list ao all elements in either sets. ; ; @history ; ; ; @version ; $Id$ ; ;- FUNCTION union, a, b ; compile_opt idl2, strictarrsubs ; IF a[0] LT 0 THEN RETURN, b ;A union NULL = a IF b[0] LT 0 THEN RETURN, a ;B union NULL = b RETURN, Where(Histogram([a,b], OMin = omin)) + omin ; Return combined set END