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.3 KB
|
Line | |
---|
1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; calculate the different elements of 2 matrix of positive whole numbers. |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Calculation |
---|
8 | ; |
---|
9 | ; @param a {in}{required} |
---|
10 | ; arrays of positive integers, which need |
---|
11 | ; not be sorted. Duplicate elements are ignored, as they have no |
---|
12 | ; effect on the result |
---|
13 | ; |
---|
14 | ; @param b {in}{required} |
---|
15 | ; see a |
---|
16 | ; |
---|
17 | ; @returns |
---|
18 | ; tableau |
---|
19 | ; |
---|
20 | ; @restrictions |
---|
21 | ; The empty set is denoted by an array with the first element equal to |
---|
22 | ; -1. |
---|
23 | ; |
---|
24 | ; @restrictions |
---|
25 | ; These functions will not be efficient on sparse sets with wide |
---|
26 | ; ranges, as they trade memory for efficiency. The HISTOGRAM function |
---|
27 | ; is used, which creates arrays of size equal to the range of the |
---|
28 | ; resulting set. |
---|
29 | ; |
---|
30 | ; @examples |
---|
31 | ; |
---|
32 | ; IDL> a = [2,4,6,8] |
---|
33 | ; IDL> b = [6,1,3,2] |
---|
34 | ; IDL> different(a,b) = [ 4, 8] ; Elements in A but not in B |
---|
35 | ; |
---|
36 | ; @history |
---|
37 | ; <a href="http://www.dfanning.com/tips/set_operations.html"/> |
---|
38 | ; |
---|
39 | ; @version |
---|
40 | ; $Id$ |
---|
41 | ; |
---|
42 | ;- |
---|
43 | FUNCTION different, a, b |
---|
44 | ; |
---|
45 | compile_opt idl2, strictarrsubs |
---|
46 | ; |
---|
47 | |
---|
48 | ; = a and (not b) = elements in A but not in B |
---|
49 | |
---|
50 | mina = Min(a, Max=maxa) |
---|
51 | minb = Min(b, Max=maxb) |
---|
52 | IF (minb GT maxa) OR (maxb LT mina) THEN RETURN, a ;No intersection... |
---|
53 | r = Where(Histogram(a, Min=mina, Max=maxa) $ |
---|
54 | *(1-Histogram(b, Min=mina, Max=maxa)), count) |
---|
55 | IF count eq 0 THEN RETURN, -1 ELSE RETURN, r + mina |
---|
56 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.