Changeset 136 for trunk/SRC/Matrix


Ignore:
Timestamp:
07/10/06 17:20:19 (18 years ago)
Author:
pinsard
Message:

some improvements and corrections in some .pro file according to
aspell and idldoc log file

Location:
trunk/SRC/Matrix
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Matrix/cmapply.pro

    r134 r136  
    1 ;; Utility function, adapted from CMPRODUCT 
    21;+ 
     2; @file_comments 
     3; Utility function, adapted from CMPRODUCT 
     4; 
     5; @version $Id$ 
     6; 
    37; @todo seb 
    48;- 
     
    2024end 
    2125 
    22 ;; Utility function, used to collect collaped dimensions 
    2326;+ 
     27; @file_comments 
     28; cmapply_redim : Utility function, used to collect collaped dimensions 
     29; 
    2430; @todo seb 
    2531;- 
     
    5359;+ 
    5460; 
    55 ; @file_comments  
     61; @file_comments 
    5662; Applies a function to specified dimensions of an array 
    5763; 
    58 ;   Description: 
    59 ; 
    60 ;      CMAPPLY will apply one of a few select functions to specified  
    61 ;   dimensions of an array.  Unlike some IDL functions, you *do* have 
    62 ;   a choice of which dimensions that are to be "collapsed" by this 
    63 ;   function.  Iterative loops are avoided where possible, for  
    64 ;   performance reasons. 
     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. 
    6571; 
    6672;   The possible functions are:             (and number of loop iterations:) 
     
    102108; @categories Arrays 
    103109; 
    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; 
    150159;   First example:  Shows how CMAPPLY can be used to total the second dimension of the 
    151160;   array called IN.  This is equivalent to OUT = TOTAL(IN, 2) 
     
    190199;   Changed usage message to not bomb, 24 Mar 2000, CM 
    191200;   Signficant rewrite for *, MIN and MAX (inspired by Todd Clements 
    192 ;     <Todd_Clements@alumni.hmc.edu>); FOR loop indices are now type 
     201;     <Todd_Clements\@alumni.hmc.edu>); FOR loop indices are now type 
    193202;     LONG; copying terms are liberalized, CM, 22, Aug 2000 
    194203;   More efficient MAX/MIN (inspired by Alex Schuster), CM, 25 Jan 
     
    199208; 
    200209;  Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 
    201 ;  craigm@lheamail.gsfc.nasa.gov 
     210;  craigm\@lheamail.gsfc.nasa.gov 
    202211; 
    203212; @version $Id$ 
     
    293302              if newop EQ 'MIN' then return, min(newarr) 
    294303          endif 
    295            
     304 
    296305          ;; Next task: create result array 
    297306          result = make_array(totkeep, type=type) 
    298            
     307 
    299308          ;; Now either iterate over the number of output elements, or 
    300309          ;; the number of collapsed elements, whichever is smaller. 
     
    302311              ;; Iterate over the number of collapsed elements 
    303312              result[0] = reform(newarr[0,*],totkeep,/overwrite) 
    304               case newop of  
     313              case newop of 
    305314                  'MAX': for i = 1L, totcol-1 do $ 
    306315                    result[0] = result > newarr[i,*] 
     
    310319          endif else begin 
    311320              ;; Iterate over the number of output elements 
    312               case newop of  
     321              case newop of 
    313322                  'MAX': for i = 0L, totkeep-1 do result[i] = max(newarr[*,i]) 
    314323                  'MIN': for i = 0L, totkeep-1 do result[i] = min(newarr[*,i]) 
     
    332341              return, call_function(functname, newarr) 
    333342          endif 
    334            
     343 
    335344          ;; Next task: create result array 
    336345          result = make_array(totkeep, type=type) 
    337            
     346 
    338347          ;; Iterate over the number of output elements 
    339348          if n_elements(functargs) GT 0 then begin 
     
    349358      end 
    350359 
    351                
     360 
    352361  endcase 
    353362 
     
    363372    return, call_function(castfns[type], newarr) 
    364373end 
    365    
  • trunk/SRC/Matrix/cmset_op.pro

    r134 r136  
    22; @hidden 
    33; 
     4; @file_comments 
     5; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 
     6; "first" value, whatever that may mean. 
     7; 
    48; @todo seb 
    59;- 
    610; 
    7 ;; Simplified version of CMSET_OP_UNIQ which sorts, and takes the 
    8 ;; "first" value, whatever that may mean. 
    911function cmset_op_uniq, a 
    1012; 
     
    2224;+ 
    2325; 
    24 ; @file_comments  
     26; @file_comments 
    2527; Performs an AND, OR, or XOR operation between two sets 
    2628; 
    27 ;   Description: SET_OP performs three common operations between two sets. The 
    28 ;   three supported functions of OP are: 
     29; Description: SET_OP performs three common operations between two sets. The 
     30; three supported functions of OP are: 
    2931; 
    3032;        OP          Meaning 
    3133;      'AND' - to find the intersection of A and B; 
    3234;      '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 
    3436;              but not both; 
    3537; 
    3638;   Sets as defined here are one dimensional arrays composed of 
    37 ;   numeric or string types.  Comparisons of equality between elements 
     39;   numeric or string types. Comparisons of equality between elements 
    3840;   are done using the IDL EQ operator. 
    3941; 
    4042;   The complements of either set can be taken as well, by using the 
    41 ;   NOT1 and NOT2 keywords.  For example, it may be desireable to find 
     43;   NOT1 and NOT2 keywords. For example, it may be desireable to find 
    4244;   the elements in A but not B, or B but not A (they are different!). 
    4345;   The following IDL expressions achieve each of those effects: 
     
    5254; 
    5355;   NOT1 and NOT2 can only be set for the 'AND' operator, and never 
    54 ;   simultaneously.  This is because the results of an operation with 
     56;   simultaneously. This is because the results of an operation with 
    5557;   'OR' or 'XOR' and any combination of NOTs -- or with 'AND' and 
    5658;   both NOTs -- formally cannot produce a defined result. 
    5759; 
    58 ;   The implementation depends on the type of operands.  For integer 
    59 ;   types, a fast technique using HISTOGRAM is used.  However, this 
     60;   The implementation depends on the type of operands. For integer 
     61;   types, a fast technique using HISTOGRAM is used. However, this 
    6062;   algorithm becomes inefficient when the dynamic range in the data 
    61 ;   is large.  For those cases, and for other data types, a technique 
    62 ;   based on SORT() is used.  Thus the compute time should scale 
     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 
    6365;   roughly as (A+B)*ALOG(A+B) or better, rather than (A*B) for the 
    64 ;   brute force approach.  For large arrays this is a significant 
     66;   brute force approach. For large arrays this is a significant 
    6567;   benefit. 
    6668; 
    6769; @categories array 
    6870; 
    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. 
    113125; 
    114126; SEE ALSO: 
    115127; 
    116  SET_UTILS.PRO by RSI 
     128SET_UTILS.PRO by RSI 
    117129; 
    118130; @history Written, CM, 23 Feb 2000 
     
    145157; 
    146158;   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 
    152165; first or last unique element, or non-unique elements. 
    153166; Unfortunately this doesn't work because of implementation dependent 
     
    235248      if n2 GT 0 then b1 = cmset_op_uniq(b) 
    236249      n1 = n_elements(a1) < n1 & n2 = n_elements(b1) < n2 
    237       case op of  
     250      case op of 
    238251          'OR': if n1 EQ 0 then goto, RET_A1 else goto, RET_B1 
    239252         'XOR': if n1 EQ 0 then goto, RET_B1 else goto, RET_A1 
     
    255268     if kind then begin 
    256269         if count GT 0 then return, b1+n1 else return, -1L 
    257      endif          
     270     endif 
    258271     if count GT 0 then return, b[b1] else return, -1L 
    259272 endif 
     
    294307      ;; String and real types, or large int arrays 
    295308      SLOW_SET_OP: 
    296       case op of  
     309      case op of 
    297310          'OR': begin 
    298311              uu = [a,b]    ;; OR is simple; just take unique values 
     
    394407 
    395408      ;; Compute NOT cases 
    396       if keyword_set(not1) then ha = 1b - ha   
     409      if keyword_set(not1) then ha = 1b - ha 
    397410      if keyword_set(not2) then hb = 1b - hb 
    398       case op of  
     411      case op of 
    399412          ;; Boolean operations 
    400           'AND': mask = temporary(ha) AND temporary(hb)  
     413          'AND': mask = temporary(ha) AND temporary(hb) 
    401414           'OR': mask = temporary(ha)  OR temporary(hb) 
    402415          'XOR': mask = temporary(ha) XOR temporary(hb) 
     
    405418      wh = where(temporary(mask), count) 
    406419      if count EQ 0 then return, -1L 
    407        
     420 
    408421      result = temporary(wh+minn) 
    409422      if tp1 NE tp2 then return, result 
  • trunk/SRC/Matrix/congridseb.pro

    r134 r136  
    33;------------------------------------------------------------ 
    44;+ 
    5 ; @file_comment  
     5; @file_comments 
    66; Like congrid but here, it works... 
    77;        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) 
    99;       1 1 1 2 2 2 3 3 3 3 4 4 
    1010;       1 1 1 2 2 2 3 3 3 3 4 4 
    1111;       5 5 5 6 6 6 7 7 7 7 8 8 
    1212;       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) 
    1414;       1 1 1 2 2 2 3 3 3 4 4 4 
    1515;       3 3 3 4 4 4 5 5 5 6 6 6 
    1616;       5 5 5 6 6 6 7 7 7 8 8 8 
    1717;       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) 
    1919;       1 1 1 2 2 2 3 3 3 4 4 4 
    2020;       1 1 1 2 2 2 3 3 3 4 4 4 
     
    2424; @categories utilities 
    2525; 
    26 ; @param tableau {in}{required} A table 1 ou 2d 
     26; @param tableau {in}{required} 
     27; A table 1 ou 2d 
    2728; 
    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. 
    3032; 
    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. 
    3336; 
    34 ; @returns res a table dim x * y 
     37; @returns 
     38; a table dim x * y 
    3539; 
    36 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 
     40; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 
    3741;                      20/3/98 
    3842;                      18/6/1999 supression d''une horrible boucle 
     
    6468      end 
    6569      else: return, report('Mauvais nombre de parametre dans l''appel de CONGRIDSEB') 
    66    endcase             
     70   endcase 
    6771end 
  • trunk/SRC/Matrix/extrac2.pro

    r134 r136  
    44;+ 
    55; 
    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) 
    89; By default, IDL can make extractions of subdomain: 
    910; 
    10 ;      IDL> a=indgen(5,5)  
    11 ;      IDL> print, a  
     11;      IDL> a=indgen(5,5) 
     12;      IDL> print, a 
    1213;             0       1       2       3       4 
    1314;             5       6       7       8       9 
     
    1516;            15      16      17      18      19 
    1617;            20      21      22      23      24 
    17 ;      IDL> print, a[[0,2],3]  
     18;      IDL> print, a[[0,2],3] 
    1819;            15      17 
    19 ;      IDL> print, a[[0,2],*]   
     20;      IDL> print, a[[0,2],*] 
    2021;             0       2 
    2122;             5       7 
     
    2425;            20      22 
    2526; but 
    26 ;      IDL> print, a[[0,2],[3,4]]  
     27;      IDL> print, a[[0,2],[3,4]] 
    2728;            15      22 
    2829; while 
    29 ;      IDL> print, extrac2(a,[0,2],[3,4])   
     30;      IDL> print, extrac2(a,[0,2],[3,4]) 
    3031;            15      17 
    3132;            20      22 
     
    3334; @categories utilities 
    3435; 
    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 
    3638; 
    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. 
    4043; 
    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. 
    4246; 
    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: 
    4462;  
    45 ; @param index4 {in}{required} the same thing that index1 but for dim 4. 
     63; IDL> res=extrac2(A,[2,3,7],[0,1]) 
    4664; 
    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 
    4873; 
    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) 
    6775;                       12/1/1999 
    6876;                       29/4/1999: correction of a bug and complement of the heading 
     
    8694   if n_params() NE taille[0]+1 THEN $ 
    8795    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 
    8997      if size(index4,/type) EQ 7 then index4 = lindgen(taille[4]) $ 
    9098      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 
    94102      if size(index3,/type) EQ 7 then index3 = lindgen(taille[3]) $ 
    95103      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 
    99107      if size(index2,/type) EQ 7 then index2 = lindgen(taille[2]) $ 
    100108      ELSE index2 = long(index2) 
    101       ny = n_elements(index2)  
     109      ny = n_elements(index2) 
    102110   ENDIF 
    103    IF n_params() GE 2 THEN BEGIN  
     111   IF n_params() GE 2 THEN BEGIN 
    104112      if size(index1,/type) EQ 7 then index1 = lindgen(taille[1]) $ 
    105113      ELSE index1 = long(index1) 
    106       nx = n_elements(index1)  
     114      nx = n_elements(index1) 
    107115   ENDIF 
    108     
     116 
    109117;------------------------------------------------------------ 
    110118; construction of an array of indexes and of results following the size of array 
     
    115123         index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 
    116124         res = array[index] 
    117       END  
     125      END 
    118126      3:BEGIN 
    119127         index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 
     
    121129          +taille[1]*taille[2]*replicate(1, nx*ny)#index3 
    122130         res = array[reform(index, nx, ny, nz, /over)] 
    123       END  
     131      END 
    124132      4:BEGIN 
    125133         index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 
     
    129137          +taille[1]*taille[2]*taille[3]*replicate(1, nx*ny*nz)#index4 
    130138         res = array[reform(index, nx, ny, nz, nz, /over)] 
    131       END  
     139      END 
    132140   endcase 
    133141 
Note: See TracChangeset for help on using the changeset viewer.