Last change
on this file since 298 was
232,
checked in by pinsard, 17 years ago
|
improvements/corrections of some *.pro headers
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[230] | 3 | ; @file_comments |
---|
[163] | 4 | ; calculate the different elements of 2 matrix of positive whole numbers. |
---|
[2] | 5 | ; |
---|
[157] | 6 | ; @categories |
---|
| 7 | ; Calculation |
---|
[2] | 8 | ; |
---|
[232] | 9 | ; @param a {in}{required} |
---|
[230] | 10 | ; arrays of positive integers, which need |
---|
[2] | 11 | ; not be sorted. Duplicate elements are ignored, as they have no |
---|
| 12 | ; effect on the result |
---|
| 13 | ; |
---|
[232] | 14 | ; @param b {in}{required} |
---|
[230] | 15 | ; see a |
---|
[2] | 16 | ; |
---|
[230] | 17 | ; @returns |
---|
| 18 | ; tableau |
---|
[2] | 19 | ; |
---|
[232] | 20 | ; @restrictions |
---|
[230] | 21 | ; The empty set is denoted by an array with the first element equal to |
---|
[2] | 22 | ; -1. |
---|
| 23 | ; |
---|
[232] | 24 | ; @restrictions |
---|
[230] | 25 | ; These functions will not be efficient on sparse sets with wide |
---|
[2] | 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 | ; |
---|
[133] | 30 | ; @examples |
---|
[2] | 31 | ; |
---|
[230] | 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 |
---|
[2] | 35 | ; |
---|
[230] | 36 | ; @history |
---|
[232] | 37 | ; <a href="http://www.dfanning.com/tips/set_operations.html"/> |
---|
[2] | 38 | ; |
---|
[230] | 39 | ; @version |
---|
| 40 | ; $Id$ |
---|
[133] | 41 | ; |
---|
[2] | 42 | ;- |
---|
[231] | 43 | ; |
---|
[230] | 44 | FUNCTION different, a, b |
---|
[114] | 45 | ; |
---|
| 46 | compile_opt idl2, strictarrsubs |
---|
| 47 | ; |
---|
[2] | 48 | |
---|
| 49 | ; = a and (not b) = elements in A but not in B |
---|
| 50 | |
---|
| 51 | mina = Min(a, Max=maxa) |
---|
| 52 | minb = Min(b, Max=maxb) |
---|
| 53 | IF (minb GT maxa) OR (maxb LT mina) THEN RETURN, a ;No intersection... |
---|
| 54 | r = Where(Histogram(a, Min=mina, Max=maxa) $ |
---|
| 55 | *(1-Histogram(b, Min=mina, Max=maxa)), count) |
---|
| 56 | IF count eq 0 THEN RETURN, -1 ELSE RETURN, r + mina |
---|
| 57 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.