Changeset 136 for trunk/SRC/Matrix
- Timestamp:
- 07/10/06 17:20:19 (18 years ago)
- Location:
- trunk/SRC/Matrix
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Matrix/cmapply.pro
r134 r136 1 ;; Utility function, adapted from CMPRODUCT2 1 ;+ 2 ; @file_comments 3 ; Utility function, adapted from CMPRODUCT 4 ; 5 ; @version $Id$ 6 ; 3 7 ; @todo seb 4 8 ;- … … 20 24 end 21 25 22 ;; Utility function, used to collect collaped dimensions23 26 ;+ 27 ; @file_comments 28 ; cmapply_redim : Utility function, used to collect collaped dimensions 29 ; 24 30 ; @todo seb 25 31 ;- … … 53 59 ;+ 54 60 ; 55 ; @file_comments 61 ; @file_comments 56 62 ; Applies a function to specified dimensions of an array 57 63 ; 58 ; 59 ; 60 ; CMAPPLY will apply one of a few select functions to specified61 ; 62 ; 63 ; function. Iterative loops are avoided where possible, for64 ; 64 ; Description: 65 ; 66 ; CMAPPLY will apply one of a few select functions to specified 67 ; dimensions of an array. Unlike some IDL functions, you *do* have 68 ; a choice of which dimensions that are to be "collapsed" by this 69 ; function. Iterative loops are avoided where possible, for 70 ; performance reasons. 65 71 ; 66 72 ; The possible functions are: (and number of loop iterations:) … … 102 108 ; @categories Arrays 103 109 ; 104 ; @param OP {in}{required} The operation to perform, as a string. May be upper or lower 105 ; case. 106 ; 107 ; If a user-defined operation is to be passed, then OP is of 108 ; the form, 'USER:FUNCTNAME', where FUNCTNAME is the name of 109 ; the user-defined function. 110 ; 111 ; @param ARRAY {in}{required} An array of values to be operated on. Must not be of type 112 ; STRING (7) or STRUCTURE (8). 113 ; 114 ; @param DIMS {in}{optional}{default=1 (ie, first dimension)} 115 ; An array of dimensions that are to be "collapsed", where 116 ; the the first dimension starts with 1 (ie, same convention 117 ; as IDL function TOTAL). Whereas TOTAL only allows one 118 ; dimension to be added, you can specify multiple dimensions 119 ; to CMAPPLY. Order does not matter, since all operations 120 ; are associative and transitive. NOTE: the dimensions refer 121 ; to the *input* array, not the output array. IDL allows a 122 ; maximum of 8 dimensions. 123 ; DEFAULT: 1 (ie, first dimension) 124 ; 125 ; @keyword DOUBLE Set this if you wish the internal computations to be done 126 ; in double precision if necessary. If ARRAY is double 127 ; precision (real or complex) then DOUBLE=1 is implied. 128 ; DEFAULT: not set 129 ; 130 ; @keyword TYPE Set this to the IDL code of the desired output type (refer 131 ; to documentation of SIZE()). Internal results will be 132 ; rounded to the nearest integer if the output type is an 133 ; integer type. 134 ; DEFAULT: same is input type 135 ; 136 ; @keyword FUNCTARGS If OP is 'USER:...', then the contents of this keyword 137 ; are passed to the user function using the _EXTRA 138 ; mechanism. This way you can pass additional data to 139 ; your user-supplied function, via keywords, without 140 ; using common blocks. 141 ; DEFAULT: undefined (i.e., no keywords passed by _EXTRA) 142 ; 143 ; @returns An array of the required TYPE, whose elements are the result of 144 ; the requested operation. Depending on the operation and number of 145 ; elements in the input array, the result may be vulnerable to 146 ; overflow or underflow. 147 ; 148 ; @examples 149 ; 110 ; @param OP {in}{required} 111 ; The operation to perform, as a string. May be upper or lower case. 112 ; 113 ; If a user-defined operation is to be passed, then OP is of 114 ; the form, 'USER:FUNCTNAME', where FUNCTNAME is the name of 115 ; the user-defined function. 116 ; 117 ; @param ARRAY {in}{required} 118 ; An array of values to be operated on. 119 ; Must not be of type STRING (7) or STRUCTURE (8). 120 ; 121 ; @param dimapply {in}{optional}{default=1 (ie, first dimension)} 122 ; An array of dimensions that are to be "collapsed", where 123 ; the the first dimension starts with 1 (ie, same convention 124 ; as IDL function TOTAL). Whereas TOTAL only allows one 125 ; dimension to be added, you can specify multiple dimensions 126 ; to CMAPPLY. Order does not matter, since all operations 127 ; are associative and transitive. NOTE: the dimensions refer 128 ; to the *input* array, not the output array. IDL allows a 129 ; maximum of 8 dimensions. 130 ; 131 ; @keyword DOUBLE {default=not set} 132 ; Set this if you wish the internal computations to be done 133 ; in double precision if necessary. If ARRAY is double 134 ; precision (real or complex) then DOUBLE=1 is implied. 135 ; 136 ; @keyword TYPE 137 ; Set this to the IDL code of the desired output type (refer 138 ; to documentation of SIZE()). Internal results will be 139 ; rounded to the nearest integer if the output type is an 140 ; integer type. 141 ; DEFAULT: same is input type 142 ; 143 ; @keyword FUNCTARGS 144 ; If OP is 'USER:...', then the contents of this keyword 145 ; are passed to the user function using the _EXTRA 146 ; mechanism. This way you can pass additional data to 147 ; your user-supplied function, via keywords, without 148 ; using common blocks. 149 ; DEFAULT: undefined (i.e., no keywords passed by _EXTRA) 150 ; 151 ; @returns 152 ; An array of the required TYPE, whose elements are the result of 153 ; the requested operation. Depending on the operation and number of 154 ; elements in the input array, the result may be vulnerable to 155 ; overflow or underflow. 156 ; 157 ; @examples 158 ; 150 159 ; First example: Shows how CMAPPLY can be used to total the second dimension of the 151 160 ; array called IN. This is equivalent to OUT = TOTAL(IN, 2) … … 190 199 ; Changed usage message to not bomb, 24 Mar 2000, CM 191 200 ; Signficant rewrite for *, MIN and MAX (inspired by Todd Clements 192 ; <Todd_Clements @alumni.hmc.edu>); FOR loop indices are now type201 ; <Todd_Clements\@alumni.hmc.edu>); FOR loop indices are now type 193 202 ; LONG; copying terms are liberalized, CM, 22, Aug 2000 194 203 ; More efficient MAX/MIN (inspired by Alex Schuster), CM, 25 Jan … … 199 208 ; 200 209 ; Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 201 ; craigm @lheamail.gsfc.nasa.gov210 ; craigm\@lheamail.gsfc.nasa.gov 202 211 ; 203 212 ; @version $Id$ … … 293 302 if newop EQ 'MIN' then return, min(newarr) 294 303 endif 295 304 296 305 ;; Next task: create result array 297 306 result = make_array(totkeep, type=type) 298 307 299 308 ;; Now either iterate over the number of output elements, or 300 309 ;; the number of collapsed elements, whichever is smaller. … … 302 311 ;; Iterate over the number of collapsed elements 303 312 result[0] = reform(newarr[0,*],totkeep,/overwrite) 304 case newop of 313 case newop of 305 314 'MAX': for i = 1L, totcol-1 do $ 306 315 result[0] = result > newarr[i,*] … … 310 319 endif else begin 311 320 ;; Iterate over the number of output elements 312 case newop of 321 case newop of 313 322 'MAX': for i = 0L, totkeep-1 do result[i] = max(newarr[*,i]) 314 323 'MIN': for i = 0L, totkeep-1 do result[i] = min(newarr[*,i]) … … 332 341 return, call_function(functname, newarr) 333 342 endif 334 343 335 344 ;; Next task: create result array 336 345 result = make_array(totkeep, type=type) 337 346 338 347 ;; Iterate over the number of output elements 339 348 if n_elements(functargs) GT 0 then begin … … 349 358 end 350 359 351 360 352 361 endcase 353 362 … … 363 372 return, call_function(castfns[type], newarr) 364 373 end 365 -
trunk/SRC/Matrix/cmset_op.pro
r134 r136 2 2 ; @hidden 3 3 ; 4 ; @file_comments 5 ; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 6 ; "first" value, whatever that may mean. 7 ; 4 8 ; @todo seb 5 9 ;- 6 10 ; 7 ;; Simplified version of CMSET_OP_UNIQ which sorts, and takes the8 ;; "first" value, whatever that may mean.9 11 function cmset_op_uniq, a 10 12 ; … … 22 24 ;+ 23 25 ; 24 ; @file_comments 26 ; @file_comments 25 27 ; Performs an AND, OR, or XOR operation between two sets 26 28 ; 27 ; Description: SET_OP performs three common operations between two sets.The28 ; 29 ; Description: SET_OP performs three common operations between two sets. The 30 ; three supported functions of OP are: 29 31 ; 30 32 ; OP Meaning 31 33 ; 'AND' - to find the intersection of A and B; 32 34 ; 'OR' - to find the union of A and B; 33 ; 'XOR' - to find the those elements who are members of A or B 35 ; 'XOR' - to find the those elements who are members of A or B 34 36 ; but not both; 35 37 ; 36 38 ; Sets as defined here are one dimensional arrays composed of 37 ; numeric or string types. 39 ; numeric or string types. Comparisons of equality between elements 38 40 ; are done using the IDL EQ operator. 39 41 ; 40 42 ; The complements of either set can be taken as well, by using the 41 ; NOT1 and NOT2 keywords. 43 ; NOT1 and NOT2 keywords. For example, it may be desireable to find 42 44 ; the elements in A but not B, or B but not A (they are different!). 43 45 ; The following IDL expressions achieve each of those effects: … … 52 54 ; 53 55 ; NOT1 and NOT2 can only be set for the 'AND' operator, and never 54 ; simultaneously. 56 ; simultaneously. This is because the results of an operation with 55 57 ; 'OR' or 'XOR' and any combination of NOTs -- or with 'AND' and 56 58 ; both NOTs -- formally cannot produce a defined result. 57 59 ; 58 ; The implementation depends on the type of operands. 59 ; types, a fast technique using HISTOGRAM is used. 60 ; The implementation depends on the type of operands. For integer 61 ; types, a fast technique using HISTOGRAM is used. However, this 60 62 ; algorithm becomes inefficient when the dynamic range in the data 61 ; is large. 62 ; based on SORT() is used. 63 ; is large. For those cases, and for other data types, a technique 64 ; based on SORT() is used. Thus the compute time should scale 63 65 ; roughly as (A+B)*ALOG(A+B) or better, rather than (A*B) for the 64 ; brute force approach. 66 ; brute force approach. For large arrays this is a significant 65 67 ; benefit. 66 68 ; 67 69 ; @categories array 68 70 ; 69 ; @param A {in}{required} The two sets to be operated on. A one dimensional array of 70 ; either numeric or string type. A and B must be of the same 71 ; type. Empty sets are permitted, and are either represented 72 ; as an undefined variable, or by setting EMPTY1 or EMPTY2. 73 ; 74 ; @param B {in}{required} See A 75 ; 76 ; @param OP {in}{required} a string, the operation to be performed. Must be one of 77 ; 'AND', 'OR' or 'XOR' (lower or mixed case is permitted). 78 ; Other operations will cause an error message to be produced. 79 ; 80 ; @keyword NOT1 If set and OP is 'AND', then the complement of A (for 81 ; NOT1) or B (for NOT2) will be used in the operation. 82 ; NOT1 and NOT2 cannot be set simultaneously. 83 ; 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 93 ; values themselves. The "slower" set operations are always 94 ; performed in this case. 95 ; 96 ; The indices refer to the *combined* array [A,B]. To 97 ; clarify, in the following call: I = CMSET_OP(..., /INDEX); 98 ; returned values from 0 to NA-1 refer to A[I], and values 99 ; from NA to NA+NB-1 refer to B[I-NA]. 100 ; 101 ; @keyword COUNT upon return, the number of elements in the result set. 102 ; This is only important when the result set is the empty 103 ; set, in which case COUNT is set to zero. 104 ; 105 ; @returns The resulting set as a one-dimensional array. The set may be 106 ; represented by either an array of data values (default), or an 107 ; array of indices (if INDEX is set). Duplicate elements, if any, 108 ; are removed, and element order may not be preserved. 109 ; 110 ; The empty set is represented as a return value of -1L, and COUNT 111 ; is set to zero. Note that the only way to recognize the empty set 112 ; is to examine COUNT. 71 ; @param A {in}{required} 72 ; The two sets to be operated on. A one dimensional array of 73 ; either numeric or string type. A and B must be of the same 74 ; type. Empty sets are permitted, and are either represented 75 ; as an undefined variable, or by setting EMPTY1 or EMPTY2. 76 ; 77 ; @param B {in}{required} 78 ; See A 79 ; 80 ; @param OP0 {in}{required} 81 ; a string, the operation to be performed. Must be one of 82 ; 'AND', 'OR' or 'XOR' (lower or mixed case is permitted). 83 ; Other operations will cause an error message to be produced. 84 ; 85 ; @keyword NOT1 86 ; If set and OP is 'AND', then the complement of A (for 87 ; NOT1) or B (for NOT2) will be used in the operation. 88 ; NOT1 and NOT2 cannot be set simultaneously. 89 ; 90 ; @keyword NOT2 91 ; See NOT1 92 ; 93 ; @keyword EMPTY1 94 ; If set, then A (for EMPTY1) or B (for EMPTY2) are 95 ; assumed to be the empty set. The actual values 96 ; passed as A or B are then ignored. 97 ; 98 ; @keyword EMPTY2 99 ; See EMPTY1 100 ; 101 ; @keyword INDEX 102 ; if set, then return a list of indices instead of the array 103 ; values themselves. The "slower" set operations are always 104 ; performed in this case. 105 ; 106 ; The indices refer to the *combined* array [A,B]. To 107 ; clarify, in the following call: I = CMSET_OP(..., /INDEX); 108 ; returned values from 0 to NA-1 refer to A[I], and values 109 ; from NA to NA+NB-1 refer to B[I-NA]. 110 ; 111 ; @keyword COUNT 112 ; upon return, the number of elements in the result set. 113 ; This is only important when the result set is the empty 114 ; set, in which case COUNT is set to zero. 115 ; 116 ; @returns 117 ; The resulting set as a one-dimensional array. The set may be 118 ; represented by either an array of data values (default), or an 119 ; array of indices (if INDEX is set). Duplicate elements, if any, 120 ; are removed, and element order may not be preserved. 121 ; 122 ; The empty set is represented as a return value of -1L, and COUNT 123 ; is set to zero. Note that the only way to recognize the empty set 124 ; is to examine COUNT. 113 125 ; 114 126 ; SEE ALSO: 115 127 ; 116 ; 128 ; SET_UTILS.PRO by RSI 117 129 ; 118 130 ; @history Written, CM, 23 Feb 2000 … … 145 157 ; 146 158 ; 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 159 ; craigm\@lheamail.gsfc.nasa.gov 160 ; 161 ; @version $Id$ 162 ; 163 ; @examples 164 ; Utility function, similar to UNIQ, but allowing choice of taking 152 165 ; first or last unique element, or non-unique elements. 153 166 ; Unfortunately this doesn't work because of implementation dependent … … 235 248 if n2 GT 0 then b1 = cmset_op_uniq(b) 236 249 n1 = n_elements(a1) < n1 & n2 = n_elements(b1) < n2 237 case op of 250 case op of 238 251 'OR': if n1 EQ 0 then goto, RET_A1 else goto, RET_B1 239 252 'XOR': if n1 EQ 0 then goto, RET_B1 else goto, RET_A1 … … 255 268 if kind then begin 256 269 if count GT 0 then return, b1+n1 else return, -1L 257 endif 270 endif 258 271 if count GT 0 then return, b[b1] else return, -1L 259 272 endif … … 294 307 ;; String and real types, or large int arrays 295 308 SLOW_SET_OP: 296 case op of 309 case op of 297 310 'OR': begin 298 311 uu = [a,b] ;; OR is simple; just take unique values … … 394 407 395 408 ;; Compute NOT cases 396 if keyword_set(not1) then ha = 1b - ha 409 if keyword_set(not1) then ha = 1b - ha 397 410 if keyword_set(not2) then hb = 1b - hb 398 case op of 411 case op of 399 412 ;; Boolean operations 400 'AND': mask = temporary(ha) AND temporary(hb) 413 'AND': mask = temporary(ha) AND temporary(hb) 401 414 'OR': mask = temporary(ha) OR temporary(hb) 402 415 'XOR': mask = temporary(ha) XOR temporary(hb) … … 405 418 wh = where(temporary(mask), count) 406 419 if count EQ 0 then return, -1L 407 420 408 421 result = temporary(wh+minn) 409 422 if tp1 NE tp2 then return, result -
trunk/SRC/Matrix/congridseb.pro
r134 r136 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; @file_comment 5 ; @file_comments 6 6 ; Like congrid but here, it works... 7 7 ; example: 8 ; IDL> print, congrid([[1,2,3,4],[5,6,7,8]],12,4)8 ; IDL> print, congrid([[1,2,3,4],[5,6,7,8]],12,4) 9 9 ; 1 1 1 2 2 2 3 3 3 3 4 4 10 10 ; 1 1 1 2 2 2 3 3 3 3 4 4 11 11 ; 5 5 5 6 6 6 7 7 7 7 8 8 12 12 ; 5 5 5 6 6 6 7 7 7 7 8 8 13 ; IDL> print, rebin([[1,2,3,4],[5,6,7,8]],12,4)13 ; IDL> print, rebin([[1,2,3,4],[5,6,7,8]],12,4) 14 14 ; 1 1 1 2 2 2 3 3 3 4 4 4 15 15 ; 3 3 3 4 4 4 5 5 5 6 6 6 16 16 ; 5 5 5 6 6 6 7 7 7 8 8 8 17 17 ; 5 5 5 6 6 6 7 7 7 8 8 8 18 ; IDL> print, congridseb([[1,2,3,4],[5,6,7,8]],12,4)18 ; IDL> print, congridseb([[1,2,3,4],[5,6,7,8]],12,4) 19 19 ; 1 1 1 2 2 2 3 3 3 4 4 4 20 20 ; 1 1 1 2 2 2 3 3 3 4 4 4 … … 24 24 ; @categories utilities 25 25 ; 26 ; @param tableau {in}{required} A table 1 ou 2d 26 ; @param tableau {in}{required} 27 ; A table 1 ou 2d 27 28 ; 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. 29 ; @param x {in}{required} 30 ; dimension in x of the result which must be 31 ; a multiple of the dimension in x of the table. 30 32 ; 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. 33 ; @param y {in}{required} 34 ; dimension in y of the result which must be 35 ; a multiple of the dimension in y of the table. 33 36 ; 34 ; @returns res a table dim x * y 37 ; @returns 38 ; a table dim x * y 35 39 ; 36 ; @history Sebastien Masson (smasson @lodyc.jussieu.fr)40 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 37 41 ; 20/3/98 38 42 ; 18/6/1999 supression d''une horrible boucle … … 64 68 end 65 69 else: return, report('Mauvais nombre de parametre dans l''appel de CONGRIDSEB') 66 endcase 70 endcase 67 71 end -
trunk/SRC/Matrix/extrac2.pro
r134 r136 4 4 ;+ 5 5 ; 6 ; @fie-comments 7 ; extractoin of subdomains of matrixes; Even if the subdomain is "pierced" (see the example) 6 ; @file_comments 7 ; extraction of subdomains of matrixes; 8 ; Even if the subdomain is "pierced" (see the example) 8 9 ; By default, IDL can make extractions of subdomain: 9 10 ; 10 ; IDL> a=indgen(5,5) 11 ; IDL> print, a 11 ; IDL> a=indgen(5,5) 12 ; IDL> print, a 12 13 ; 0 1 2 3 4 13 14 ; 5 6 7 8 9 … … 15 16 ; 15 16 17 18 19 16 17 ; 20 21 22 23 24 17 ; IDL> print, a[[0,2],3] 18 ; IDL> print, a[[0,2],3] 18 19 ; 15 17 19 ; IDL> print, a[[0,2],*] 20 ; IDL> print, a[[0,2],*] 20 21 ; 0 2 21 22 ; 5 7 … … 24 25 ; 20 22 25 26 ; but 26 ; IDL> print, a[[0,2],[3,4]] 27 ; IDL> print, a[[0,2],[3,4]] 27 28 ; 15 22 28 29 ; while 29 ; IDL> print, extrac2(a,[0,2],[3,4]) 30 ; IDL> print, extrac2(a,[0,2],[3,4]) 30 31 ; 15 17 31 32 ; 20 22 … … 33 34 ; @categories utilities 34 35 ; 35 ; @param array {in}{required} a 1,2,3 or 4 dim input array 36 ; @param array {in}{required} 37 ; a 1,2,3 or 4 dim input array 36 38 ; 37 ; @param index1 {in}{required} can have 2 forms: 38 ; 1)a vector containing indexes of lines we want to keep 39 ; 2)the string '*' if we want to keep all lines. 39 ; @param index1 {in}{required} 40 ; can have 2 forms: 41 ; 1)a vector containing indexes of lines we want to keep 42 ; 2)the string '*' if we want to keep all lines. 40 43 ; 41 ; @param index2 {in}{required} the same thing that index1 but for dim 2. 44 ; @param index2 {in}{required} 45 ; the same thing that index1 but for dim 2. 42 46 ; 43 ; @param index3 {in}{required} the same thing that index1 but for dim 3. 47 ; @param index3 {in}{required} 48 ; the same thing that index1 but for dim 3. 49 ; 50 ; @param index4 {in}{required} 51 ; the same thing that index1 but for dim 4. 52 ; 53 ; @returns 54 ; a matrix 1,2,3 or 4d extract from input array 55 ; 56 ; @restrictions 57 ; -1 in case of mistake 58 ; 59 ; @examples 60 ; I have a dim 2 matrix named A. I want extract a small intersection 61 ; matrix 2d of the line 2,3 and 7 and of the column 0 and 1: 44 62 ; 45 ; @param index4 {in}{required} the same thing that index1 but for dim 4.63 ; IDL> res=extrac2(A,[2,3,7],[0,1]) 46 64 ; 47 ; @returns a matrix 1,2,3 or 4d extract from input array 65 ; other ex: 66 ; IDL> print, a 67 ; a b c 68 ; d e f 69 ; g h i 70 ; IDL> print, extrac2(a,[0,2],[0,2]) 71 ; a c 72 ; g i 48 73 ; 49 ; @restrictions res=-1 in case of mistake 50 ; 51 ; 52 ; @examples I have a dim 2 matrix named A. I want extract a small intersection 53 ; matrix 2d of the line 2,3 and 7 and of the column 0 and 1: 54 ; 55 ; res=extrac2(A,[2,3,7],[0,1]) 56 ; 57 ;other ex: 58 ; IDL> print, a 59 ; a b c 60 ; d e f 61 ; g h i 62 ; IDL> print, extrac2(a,[0,2],[0,2]) 63 ; a c 64 ; g i 65 ; 66 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 74 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 67 75 ; 12/1/1999 68 76 ; 29/4/1999: correction of a bug and complement of the heading … … 86 94 if n_params() NE taille[0]+1 THEN $ 87 95 return, report('we need as many indexes as the number of dimensions of the input array') 88 IF n_params() GE 5 THEN BEGIN 96 IF n_params() GE 5 THEN BEGIN 89 97 if size(index4,/type) EQ 7 then index4 = lindgen(taille[4]) $ 90 98 ELSE index4 = long(index4) 91 nt = n_elements(index4) 92 ENDIF 93 IF n_params() GE 4 THEN BEGIN 99 nt = n_elements(index4) 100 ENDIF 101 IF n_params() GE 4 THEN BEGIN 94 102 if size(index3,/type) EQ 7 then index3 = lindgen(taille[3]) $ 95 103 ELSE index3 = long(index3) 96 nz = n_elements(index3) 97 ENDIF 98 IF n_params() GE 3 THEN BEGIN 104 nz = n_elements(index3) 105 ENDIF 106 IF n_params() GE 3 THEN BEGIN 99 107 if size(index2,/type) EQ 7 then index2 = lindgen(taille[2]) $ 100 108 ELSE index2 = long(index2) 101 ny = n_elements(index2) 109 ny = n_elements(index2) 102 110 ENDIF 103 IF n_params() GE 2 THEN BEGIN 111 IF n_params() GE 2 THEN BEGIN 104 112 if size(index1,/type) EQ 7 then index1 = lindgen(taille[1]) $ 105 113 ELSE index1 = long(index1) 106 nx = n_elements(index1) 114 nx = n_elements(index1) 107 115 ENDIF 108 116 109 117 ;------------------------------------------------------------ 110 118 ; construction of an array of indexes and of results following the size of array … … 115 123 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 116 124 res = array[index] 117 END 125 END 118 126 3:BEGIN 119 127 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 … … 121 129 +taille[1]*taille[2]*replicate(1, nx*ny)#index3 122 130 res = array[reform(index, nx, ny, nz, /over)] 123 END 131 END 124 132 4:BEGIN 125 133 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 … … 129 137 +taille[1]*taille[2]*taille[3]*replicate(1, nx*ny*nz)#index4 130 138 res = array[reform(index, nx, ny, nz, nz, /over)] 131 END 139 END 132 140 endcase 133 141
Note: See TracChangeset
for help on using the changeset viewer.