Re: Summary: comparing arrays [message #8] |
Tue, 12 March 1991 10:31 |
rfinch
Messages: 51 Registered: March 1991
|
Member |
|
|
Here is yet a fourth way; this technique was mentioned by others.
From: RSI <idl@pprince.Colorado.EDU>
Here is solution #4 (and counting) to your array intersection problem. The
algorithm is very efficient for byte, integer, and long arrays, that
have a limited range. It will not work for other data types.
function intersect, a, b
; Return the values that are common between two arrays.
; Restrictions:
; A and B should be integers, longs, or bytes. Their combined range
; should be relatively small, as two histogram arrays of length equal
; to the combined range are created.
;
minv = min(a) < min(b) ;Smallest value
return, where((histogram(a, min=minv) ne 0) and $
(histogram(b, min=minv) ne 0))+minv
end
--
Ralph Finch 916-445-0088
rfinch@water.ca.gov ...ucbvax!ucdavis!caldwr!rfinch
Any opinions expressed are my own; they do not represent the DWR
|
|
|