Changeset 133 for trunk/SRC/Matrix
- Timestamp:
- 07/07/06 11:57:27 (18 years ago)
- Location:
- trunk/SRC/Matrix
- Files:
-
- 3 added
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Matrix/cmapply.pro
r132 r133 1 ;; Utility function, adapted from CMPRODUCT 1 2 ;+ 2 ; NAME: 3 ; CMAPPLY 4 ; 5 ; AUTHOR: 6 ; Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 7 ; craigm@lheamail.gsfc.nasa.gov 8 ; 9 ; PURPOSE: 10 ; Applies a function to specified dimensions of an array 11 ; 12 ; MAJOR TOPICS: 13 ; Arrays 14 ; 15 ; CALLING SEQUENCE: 16 ; XX = CMAPPLY(OP, ARRAY, DIMS, [/DOUBLE], [TYPE=TYPE]) 17 ; 18 ; DESCRIPTION: 19 ; CMAPPLY will apply one of a few select functions to specified 3 ; @todo seb 4 ;- 5 ; 6 function cmapply_product, x 7 ; 8 compile_opt idl2, strictarrsubs 9 ; 10 sz = size(x) 11 n = sz[1] 12 13 while n GT 1 do begin 14 if (n mod 2) EQ 1 then x[0,*] = x[0,*] * x[n-1,*] 15 n2 = floor(n/2) 16 x = x[0:n2-1,*] * x[n2:*,*] 17 n = n2 18 endwhile 19 return, reform(x[0,*], /overwrite) 20 end 21 22 ;; Utility function, used to collect collaped dimensions 23 ;+ 24 ; @todo seb 25 ;- 26 ; 27 pro cmapply_redim, newarr, dimapply, dimkeep, nkeep, totcol, totkeep 28 ; 29 compile_opt idl2, strictarrsubs 30 ; 31 sz = size(newarr) 32 ;; First task: rearrange dimensions so that the dimensions 33 ;; that are "kept" (ie, uncollapsed) are at the back 34 dimkeep = where(histogram(dimapply,min=1,max=sz[0]) ne 1, nkeep) 35 if nkeep EQ 0 then return 36 37 newarr = transpose(temporary(newarr), [dimapply-1, dimkeep]) 38 ;; totcol is the total number of collapsed elements 39 totcol = sz[dimapply[0]] 40 for i = 1, n_elements(dimapply)-1 do totcol = totcol * sz[dimapply[i]] 41 totkeep = sz[dimkeep[0]+1] 42 for i = 1, n_elements(dimkeep)-1 do totkeep = totkeep * sz[dimkeep[i]+1] 43 44 ;; this new array has two dimensions: 45 ;; * the first, all elements that will be collapsed 46 ;; * the second, all dimensions that will be preserved 47 ;; (the ordering is so that all elements to be collapsed are 48 ;; adjacent in memory) 49 newarr = reform(newarr, [totcol, totkeep], /overwrite) 50 end 51 52 ;; Main function 53 ;+ 54 ; 55 ; @file_comments 56 ; Applies a function to specified dimensions of an array 57 ; 58 ; Description: 59 ; 60 ; CMAPPLY will apply one of a few select functions to specified 20 61 ; dimensions of an array. Unlike some IDL functions, you *do* have 21 62 ; a choice of which dimensions that are to be "collapsed" by this … … 59 100 ; elements is large. 60 101 ; 61 ; 62 ; INPUTS: 63 ; 64 ; OP - The operation to perform, as a string. May be upper or lower 102 ; @categories Arrays 103 ; 104 ; @param OP {in}{required} The operation to perform, as a string. May be upper or lower 65 105 ; case. 66 106 ; … … 69 109 ; the user-defined function. 70 110 ; 71 ; ARRAY -An array of values to be operated on. Must not be of type111 ; @param ARRAY {in}{required} An array of values to be operated on. Must not be of type 72 112 ; STRING (7) or STRUCTURE (8). 73 113 ; 74 ; OPTIONAL INPUTS: 75 ; 76 ; DIMS - An array of dimensions that are to be "collapsed", where 114 ; @param DIMS {in}{optional}{default=1 (ie, first dimension)} 115 ; An array of dimensions that are to be "collapsed", where 77 116 ; the the first dimension starts with 1 (ie, same convention 78 117 ; as IDL function TOTAL). Whereas TOTAL only allows one … … 84 123 ; DEFAULT: 1 (ie, first dimension) 85 124 ; 86 ; KEYWORDS: 87 ; 88 ; DOUBLE - Set this if you wish the internal computations to be done 125 ; @keyword DOUBLE Set this if you wish the internal computations to be done 89 126 ; in double precision if necessary. If ARRAY is double 90 127 ; precision (real or complex) then DOUBLE=1 is implied. 91 128 ; DEFAULT: not set 92 129 ; 93 ; TYPE -Set this to the IDL code of the desired output type (refer130 ; @keyword TYPE Set this to the IDL code of the desired output type (refer 94 131 ; to documentation of SIZE()). Internal results will be 95 132 ; rounded to the nearest integer if the output type is an … … 97 134 ; DEFAULT: same is input type 98 135 ; 99 ; FUNCTARGS -If OP is 'USER:...', then the contents of this keyword136 ; @keyword FUNCTARGS If OP is 'USER:...', then the contents of this keyword 100 137 ; are passed to the user function using the _EXTRA 101 138 ; mechanism. This way you can pass additional data to … … 104 141 ; DEFAULT: undefined (i.e., no keywords passed by _EXTRA) 105 142 ; 106 ; RETURN VALUE: 107 ; 108 ; An array of the required TYPE, whose elements are the result of 143 ; @returns An array of the required TYPE, whose elements are the result of 109 144 ; the requested operation. Depending on the operation and number of 110 145 ; elements in the input array, the result may be vulnerable to 111 146 ; overflow or underflow. 112 147 ; 113 ; EXAMPLES: 114 ; Shows how CMAPPLY can be used to total the second dimension of the 148 ; @examples 149 ; 150 ; First example: Shows how CMAPPLY can be used to total the second dimension of the 115 151 ; array called IN. This is equivalent to OUT = TOTAL(IN, 2) 116 152 ; … … 120 156 ; OUT INT = Array[5] 121 157 ; 122 ; Second example .Input is assumed to be an 5x100 array of 1's and158 ; Second example: Input is assumed to be an 5x100 array of 1's and 123 159 ; 0's indicating the status of 5 detectors at 100 points in time. 124 160 ; The desired output is an array of 100 values, indicating whether … … 134 170 ; although there would have been more loop iterations). 135 171 ; 136 ; Third example .Shows sum over first and third dimensions in an172 ; Third example: Shows sum over first and third dimensions in an 137 173 ; array with dimensions 4x4x4: 138 174 ; … … 142 178 ; 408 472 536 600 143 179 ; 144 ; Fourth example .A user-function (MEDIAN) is used:180 ; Fourth example: A user-function (MEDIAN) is used: 145 181 ; 146 182 ; IDL> IN = RANDOMN(SEED,10,10,5) … … 151 187 ; (OUT[i,j] is the median value of IN[i,j,*]) 152 188 ; 153 ; MODIFICATION HISTORY: 154 ; Mar 1998, Written, CM 189 ; @history Mar 1998, Written, CM 155 190 ; Changed usage message to not bomb, 24 Mar 2000, CM 156 191 ; Signficant rewrite for *, MIN and MAX (inspired by Todd Clements … … 163 198 ; Correct bug in MAX/MIN initialization of RESULT, CM, 05 Dec 2002 164 199 ; 165 ; $Id$ 200 ; Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 201 ; craigm@lheamail.gsfc.nasa.gov 202 ; 203 ; @version $Id$ 166 204 ; 167 205 ;- 168 ; Copyright (C) 1998, 2000, 2002, Craig Markwardt169 ; This software is provided as is without any warranty whatsoever.170 ; Permission to use, copy, modify, and distribute modified or171 ; unmodified copies is granted, provided this copyright and disclaimer172 ; are included unchanged.173 ;-174 175 ;; Utility function, adapted from CMPRODUCT176 function cmapply_product, x177 ;178 compile_opt idl2, strictarrsubs179 ;180 sz = size(x)181 n = sz[1]182 183 while n GT 1 do begin184 if (n mod 2) EQ 1 then x[0,*] = x[0,*] * x[n-1,*]185 n2 = floor(n/2)186 x = x[0:n2-1,*] * x[n2:*,*]187 n = n2188 endwhile189 return, reform(x[0,*], /overwrite)190 end191 192 ;; Utility function, used to collect collaped dimensions193 pro cmapply_redim, newarr, dimapply, dimkeep, nkeep, totcol, totkeep194 ;195 compile_opt idl2, strictarrsubs196 ;197 sz = size(newarr)198 ;; First task: rearrange dimensions so that the dimensions199 ;; that are "kept" (ie, uncollapsed) are at the back200 dimkeep = where(histogram(dimapply,min=1,max=sz[0]) ne 1, nkeep)201 if nkeep EQ 0 then return202 203 newarr = transpose(temporary(newarr), [dimapply-1, dimkeep])204 ;; totcol is the total number of collapsed elements205 totcol = sz[dimapply[0]]206 for i = 1, n_elements(dimapply)-1 do totcol = totcol * sz[dimapply[i]]207 totkeep = sz[dimkeep[0]+1]208 for i = 1, n_elements(dimkeep)-1 do totkeep = totkeep * sz[dimkeep[i]+1]209 210 ;; this new array has two dimensions:211 ;; * the first, all elements that will be collapsed212 ;; * the second, all dimensions that will be preserved213 ;; (the ordering is so that all elements to be collapsed are214 ;; adjacent in memory)215 newarr = reform(newarr, [totcol, totkeep], /overwrite)216 end217 218 ;; Main function219 206 function cmapply, op, array, dimapply, double=dbl, type=type, $ 220 207 functargs=functargs, nocatch=nocatch -
trunk/SRC/Matrix/cmset_op.pro
r132 r133 1 1 ;+ 2 ; NAME: 3 ; CMSET_OP 4 ; 5 ; AUTHOR: 6 ; Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 7 ; craigm@lheamail.gsfc.nasa.gov 8 ; 9 ; PURPOSE: 10 ; Performs an AND, OR, or XOR operation between two sets 11 ; 12 ; CALLING SEQUENCE: 13 ; SET = CMSET_OP(A, OP, B) 14 ; 15 ; DESCRIPTION: 16 ; 17 ; SET_OP performs three common operations between two sets. The 2 ; @hidden 3 ; 4 ; @todo seb 5 ;- 6 ; 7 ;; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 8 ;; "first" value, whatever that may mean. 9 function cmset_op_uniq, a 10 ; 11 compile_opt idl2, strictarrsubs 12 ; 13 if n_elements(a) LE 1 then return, 0L 14 15 ii = sort(a) & b = a[ii] 16 wh = where(b NE shift(b, +1L), ct) 17 if ct GT 0 then return, ii[wh] 18 19 return, 0L 20 ; 21 end 22 ;+ 23 ; 24 ; @file_comments 25 ; Performs an AND, OR, or XOR operation between two sets 26 ; 27 ; Description: SET_OP performs three common operations between two sets. The 18 28 ; three supported functions of OP are: 19 29 ; … … 55 65 ; benefit. 56 66 ; 57 ; INPUTS:58 ; 59 ; A, B - the two sets to be operated on. A one dimensional array of67 ; @categories array 68 ; 69 ; @param A {in}{required} The two sets to be operated on. A one dimensional array of 60 70 ; either numeric or string type. A and B must be of the same 61 71 ; type. Empty sets are permitted, and are either represented 62 72 ; as an undefined variable, or by setting EMPTY1 or EMPTY2. 63 73 ; 64 ; OP - a string, the operation to be performed. Must be one of 74 ; @param B {in}{required} See A 75 ; 76 ; @param OP {in}{required} a string, the operation to be performed. Must be one of 65 77 ; 'AND', 'OR' or 'XOR' (lower or mixed case is permitted). 66 78 ; Other operations will cause an error message to be produced. 67 79 ; 68 ; KEYWORDS: 69 ; 70 ; NOT1, NOT2 - if set and OP is 'AND', then the complement of A (for 80 ; @keyword NOT1 If set and OP is 'AND', then the complement of A (for 71 81 ; NOT1) or B (for NOT2) will be used in the operation. 72 82 ; NOT1 and NOT2 cannot be set simultaneously. 73 83 ; 74 ; EMPTY1, EMPTY2 - if set, then A (for EMPTY1) or B (for EMPTY2) are 75 ; assumed to be the empty set. The actual values 76 ; passed as A or B are then ignored. 77 ; 78 ; INDEX - if set, then return a list of indices instead of the array 84 ; @keyword NOT2 See NOT1 85 ; 86 ; @keyword EMPTY1 If set, then A (for EMPTY1) or B (for EMPTY2) are 87 ; assumed to be the empty set. The actual values 88 ; passed as A or B are then ignored. 89 ; 90 ; @keyword EMPTY2 See EMPTY1 91 ; 92 ; @keyword INDEX if set, then return a list of indices instead of the array 79 93 ; values themselves. The "slower" set operations are always 80 94 ; performed in this case. … … 85 99 ; from NA to NA+NB-1 refer to B[I-NA]. 86 100 ; 87 ; COUNT -upon return, the number of elements in the result set.101 ; @keyword COUNT upon return, the number of elements in the result set. 88 102 ; This is only important when the result set is the empty 89 103 ; set, in which case COUNT is set to zero. 90 104 ; 91 ; RETURNS: 92 ; 93 ; The resulting set as a one-dimensional array. The set may be 105 ; @returns The resulting set as a one-dimensional array. The set may be 94 106 ; represented by either an array of data values (default), or an 95 107 ; array of indices (if INDEX is set). Duplicate elements, if any, … … 104 116 ; SET_UTILS.PRO by RSI 105 117 ; 106 ; MODIFICATION HISTORY: 107 ; Written, CM, 23 Feb 2000 118 ; @history Written, CM, 23 Feb 2000 108 119 ; Added empty set capability, CM, 25 Feb 2000 109 120 ; Documentation clarification, CM 02 Mar 2000 … … 133 144 ; range of the input variable (thanks to Will Maddox), CM, 16 Jan 2006 134 145 ; 135 ; $Id: cmset_op.pro,v 1.6 2006/01/16 19:45:22 craigm Exp $ 136 ; 137 ;- 138 ; Copyright (C) 2000, 2004, 2005, 2006, Craig Markwardt 139 ; This software is provided as is without any warranty whatsoever. 140 ; Permission to use, copy, modify, and distribute modified or 141 ; unmodified copies is granted, provided this copyright and disclaimer 142 ; are included unchanged. 143 ;- 144 145 ;; Utility function, similar to UNIQ, but allowing choice of taking 146 ;; first or last unique element, or non-unique elements. 147 ;; Unfortunately this doesn't work because of implementation dependent 148 ;; versions of the SORT() function. 149 146 ; Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 147 ; craigm@lheamail.gsfc.nasa.gov 148 ; 149 ; @version $Id: cmset_op.pro,v 1.6 2006/01/16 19:45:22 craigm Exp $ 150 ; 151 ; @examples Utility function, similar to UNIQ, but allowing choice of taking 152 ; first or last unique element, or non-unique elements. 153 ; Unfortunately this doesn't work because of implementation dependent 154 ; versions of the SORT() function. 155 ; 150 156 ; function cmset_op_uniq, a, first=first, non=non, count=ct, sort=sortit 151 157 ; if n_elements(a) LE 1 then return, 0L … … 168 174 ; end 169 175 170 ;; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 171 ;; "first" value, whatever that may mean. 172 function cmset_op_uniq, a 173 ; 174 compile_opt idl2, strictarrsubs 175 ; 176 if n_elements(a) LE 1 then return, 0L 177 178 ii = sort(a) & b = a[ii] 179 wh = where(b NE shift(b, +1L), ct) 180 if ct GT 0 then return, ii[wh] 181 182 return, 0L 183 end 176 ; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 177 ; "first" value, whatever that may mean. 178 ; 179 ;- 180 184 181 185 182 function cmset_op, a, op0, b, not1=not1, not2=not2, count=count, $ -
trunk/SRC/Matrix/congridseb.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:CONGRIDSEB 6 ; 7 ; PURPOSE:meme chose que congrid mais qui marche ... 8 ; cf par ex: 5 ; @file_comment 6 ; Like congrid but here, it works... 7 ; example: 9 8 ;IDL> print, congrid([[1,2,3,4],[5,6,7,8]],12,4) 10 9 ; 1 1 1 2 2 2 3 3 3 3 4 4 … … 23 22 ; 5 5 5 6 6 6 7 7 7 8 8 8 24 23 ; 25 ; CATEGORY:bidouille matrices24 ; @categories utilities 26 25 ; 27 ; CALLING SEQUENCE:res=congridseb(tableau,x[,y])26 ; @param tableau {in}{required} A table 1 ou 2d 28 27 ; 29 ; INPUTS:tableau:un tableau 1 ou 2d 30 ; x:dim en x du resultat doit etre un multiple de dim en x de tableau 31 ; y:dim en y du resultat doit etre un multiple de dim en y de tableau 28 ; @param x {in}{required} dimension in x of the result which must be 29 ; a multiple of the dimension in x of the table. 32 30 ; 33 ; KEYWORD PARAMETERS: 31 ; @param y {in}{required} dimension in y of the result which must be 32 ; a multiple of the dimension in y of the table. 34 33 ; 35 ; OUTPUTS:res un tableau de dim x * y34 ; @returns res a table dim x * y 36 35 ; 37 ; COMMON BLOCKS: 38 ; 39 ; SIDE EFFECTS: 40 ; 41 ; RESTRICTIONS: 42 ; 43 ; EXAMPLE: 44 ; 45 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 36 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 46 37 ; 20/3/98 47 38 ; 18/6/1999 supression d''une horrible boucle 39 ; 40 ; @version $Id$ 41 ; 48 42 ;- 49 43 ;------------------------------------------------------------ -
trunk/SRC/Matrix/different.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:different6 5 ; 7 ; PURPOSE:calcule les elements differents de 2 matrices D'ENTIERS POSITIFS 6 ; @file_comments 7 ; calculate the different elements of 2 matrix of positif whole numbers. 8 8 ; 9 ; CATEGORY:calcule sur les matrices9 ; @categories Calculation of matrixes 10 10 ; 11 ; CALLING SEQUENCE:res=different(a,b) 12 ; 13 ; INPUTS:a et b:arrays of positive integers, which need 11 ; @param a {in}{required} arrays of positive integers, which need 14 12 ; not be sorted. Duplicate elements are ignored, as they have no 15 13 ; effect on the result 16 14 ; 17 ; KEYWORD PARAMETERS:15 ; @param b {in}{required} see a 18 16 ; 19 ; OUTPUTS:tableau17 ; @returns tableau 20 18 ; 21 ; COMMON BLOCKS: 22 ; 23 ; SIDE EFFECTS: 24 ; 25 ; The empty set is denoted by an array with the first element equal to 19 ; @restrictions The empty set is denoted by an array with the first element equal to 26 20 ; -1. 27 21 ; 28 ; RESTRICTIONS: 29 ; 30 ; These functions will not be efficient on sparse sets with wide 22 ; @restrictions These functions will not be efficient on sparse sets with wide 31 23 ; ranges, as they trade memory for efficiency. The HISTOGRAM function 32 24 ; is used, which creates arrays of size equal to the range of the 33 25 ; resulting set. 34 26 ; 35 ; EXAMPLE:27 ; @examples 36 28 ; 37 29 ; a = [2,4,6,8] … … 39 31 ; different(a,b) = [ 4, 8] ; Elements in A but not in B 40 32 ; 41 ; MODIFICATION HISTORY:33 ; @history http://www.dfanning.com/tips/set_operations.html 42 34 ; 43 ; http://www.dfanning.com/tips/set_operations.html 35 ; @version $Id$ 36 ; 44 37 ;- 45 38 ;------------------------------------------------------------ -
trunk/SRC/Matrix/inter.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:inter6 5 ; 7 ; PURPOSE:calcule l''intersection de 2 matrices D'ENTIERS POSITIFS 6 ; @file_comments 7 ; calculate the intersection between 2 matrixes of whole numbers 8 8 ; 9 ; CATEGORY:calcule sur les matrices9 ; @categories calculation of matrixes 10 10 ; 11 ; CALLING SEQUENCE:res=inter(a,b) 12 ; 13 ; INPUTS:a et b:arrays of positive integers, which need not to be 11 ; @param a {in}{required} arrays of positive integers, which need not to be 14 12 ; sorted. Duplicate elements are ignored, as they have noeffect on the 15 13 ; result 16 14 ; 17 ; KEYWORD PARAMETERS:15 ; @param b {in}{required} see a 18 16 ; 19 ; OUTPUTS:tableau17 ; @returns tableau 20 18 ; 21 ; COMMON BLOCKS: 22 ; 23 ; SIDE EFFECTS: 24 ; 25 ; The empty set is denoted by an array with the first element equal to 19 ; @restrictions The empty set is denoted by an array with the first element equal to 26 20 ; -1. 27 21 ; 28 ; RESTRICTIONS: 29 ; 30 ; These functions will not be efficient on sparse sets with wide 22 ; @restrictions These functions will not be efficient on sparse sets with wide 31 23 ; ranges, as they trade memory for efficiency. The HISTOGRAM function 32 24 ; is used, which creates arrays of size equal to the range of the 33 25 ; resulting set. 34 26 ; 35 ; EXAMPLE: 27 ; @examples a = [2,4,6,8] 28 ; b = [6,1,3,2] 29 ; inter(a,b) = [ 2, 6] ; Common elements 36 30 ; 37 ; a = [2,4,6,8] 38 ; b = [6,1,3,2] 39 ; inter(a,b) = [ 2, 6] ; Common elements 31 ; @history http://www.dfanning.com/tips/set_operations.html 40 32 ; 41 ; MODIFICATION HISTORY:33 ; @version $Id$ 42 34 ; 43 ; http://www.dfanning.com/tips/set_operations.html44 35 ;- 45 36 ;------------------------------------------------------------ -
trunk/SRC/Matrix/make_selection.pro
r132 r133 1 ; $Id$2 ;-------------------------------------------------------------3 1 ;+ 4 ; NAME:5 ; MAKE_SELECTION (function)6 2 ; 7 ; PURPOSE:8 ; 3 ; file_comments 4 ; Convert an array of selected values to an index 9 5 ; array that identifies the selected values in a list 10 6 ; or data array. 11 7 ; 12 ; CATEGORY: 13 ; Tools 8 ; categories tools 9 ; 10 ; @param NAMES {in}{required} A list or array of values to choose from 14 11 ; 15 ; CALLING SEQUENCE: 16 ; index = MAKE_SELECTION(NAMES,SELNAMES [,keywords]) 12 ; @param SELNAMES {in}{required} A list of selected values 17 13 ; 18 ; INPUTS: 19 ; NAMES -> A list or array of values to choose from 20 ; 21 ; SELNAMES -> A list of selected values 22 ; 23 ; KEYWORD PARAMETERS: 24 ; ONLY_VALID -> Return only indices of found values. Values not 14 ; @keyword ONLY_VALID Return only indices of found values. Values not 25 15 ; found are skipped. Default is to return 1 index value for 26 16 ; each SELNAME, which is -1 if SELNAME is not contained in … … 29 19 ; at all. 30 20 ; 31 ; REQUIRED ->Normally, MAKE_SELECTION will return indices for21 ; @keyword REQUIRED Normally, MAKE_SELECTION will return indices for 32 22 ; all values that are found, simply ignoring the selected 33 23 ; values that are not in the NAMES array (although an error … … 35 25 ; -1 as soon as a selected value is not found. 36 26 ; 37 ; QUIET ->Suppress printing of the error message if a27 ; @keyword QUIET Suppress printing of the error message if a 38 28 ; selected value is not found (the error condition will 39 29 ; still be set). 40 30 ; 41 ; OUTPUTS: 42 ; A (long) array with indices to reference the selected values 31 ; @returns A (long) array with indices to reference the selected values 43 32 ; in the NAMES array. 44 33 ; 45 ; SUBROUTINES: 46 ; 47 ; REQUIREMENTS: 48 ; 49 ; NOTES: 50 ; If the NAMES array contains multiple entries of the same value, 34 ; @restrictions If the NAMES array contains multiple entries of the same value, 51 35 ; only the index to the first entry will be returned. 52 36 ; … … 55 39 ; (See example below) 56 40 ; 57 ; EXAMPLE: 58 ; names = [ 'Alfred','Anton','Peter','John','Mary'] 59 ; index = MAKE_SELECTION(names,['Peter','Mary']) 60 ; print,index 61 ; ; prints 2 4 41 ; @examples names = [ 'Alfred','Anton','Peter','John','Mary'] 42 ; index = MAKE_SELECTION(names,['Peter','Mary']) 43 ; print,index 44 ; ; prints 2 4 62 45 ; 63 ; vals = indgen(20)64 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9])65 ; print,index66 ; ; prints 9 -1 8 7 7 8 946 ; vals = indgen(20) 47 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9]) 48 ; print,index 49 ; ; prints 9 -1 8 7 7 8 9 67 50 ; 68 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9],/ONLY_VALID)69 ; print,index70 ; ; prints 9 8 7 7 8 951 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9],/ONLY_VALID) 52 ; print,index 53 ; ; prints 9 8 7 7 8 9 71 54 ; 72 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9],/REQUIRED)73 ; print,index74 ; ; prints -155 ; index = MAKE_SELECTION(vals,[9,-5,8,7,7,8,9],/REQUIRED) 56 ; print,index 57 ; ; prints -1 75 58 ; 59 ; @history mgs, 28 Aug 1998: VERSION 1.00 60 ; mgs, 29 Aug 1998: - changed behaviour and added ONLY_VALID keyword 76 61 ; 77 ; MODIFICATION HISTORY: 78 ; mgs, 28 Aug 1998: VERSION 1.00 79 ; mgs, 29 Aug 1998: - changed behaviour and added ONLY_VALID keyword 62 ; @version $Id$ 80 63 ; 81 64 ;- -
trunk/SRC/Matrix/union.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:union6 5 ; 7 ; PURPOSE:calcule l''union de 2 matrices D'ENTIERS POSITIFS 6 ; @file_comments 7 ; calculate tne union between 2 matrixes of whole numbers 8 8 ; 9 ; CATEGORY:calcule sur les matrices9 ; @categories calculation of matrixes 10 10 ; 11 ; CALLING SEQUENCE:res=union(a,b) 12 ; 13 ; INPUTS:a et b:arrays of positive integers, which need 11 ; @param a {in}{required} arrays of positive integers, which need 14 12 ; not be sorted. Duplicate elements are ignored, as they have no 15 13 ; effect on the result 16 14 ; 17 ; KEYWORD PARAMETERS:15 ; @param b {in}{required} see a 18 16 ; 19 ; OUTPUTS:tableau17 ; @returns tableau 20 18 ; 21 ; COMMON BLOCKS: 22 ; 23 ; SIDE EFFECTS: 24 ; 25 ; The empty set is denoted by an array with the first element equal to 19 ; @restrictions The empty set is denoted by an array with the first element equal to 26 20 ; -1. 27 21 ; 28 ; RESTRICTIONS: 29 ; 30 ; These functions will not be efficient on sparse sets with wide 22 ; @restrictions These functions will not be efficient on sparse sets with wide 31 23 ; ranges, as they trade memory for efficiency. The HISTOGRAM function 32 24 ; is used, which creates arrays of size equal to the range of the 33 25 ; resulting set. 34 26 ; 35 ; EXAMPLE: 27 ; @examples a = [2,4,6,8] 28 ; b = [6,1,3,2] 29 ; union(a,b) = [ 1, 2, 3, 4, 6, 8] ; Elements in either set 36 30 ; 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 31 ; @history http://www.dfanning.com/tips/set_operations.html 40 32 ; 41 ; MODIFICATION HISTORY:33 ; @version $Id$ 42 34 ; 43 ; http://www.dfanning.com/tips/set_operations.html44 35 ;- 45 36 ;------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.