Ignore:
Timestamp:
06/19/06 16:14:56 (18 years ago)
Author:
smasson
Message:

new compilation options (compile_opt idl2, strictarrsubs) in each routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/MATRICE/cmset_op.pro

    r84 r114  
    154154;   if keyword_set(sortit) then begin 
    155155;       ;; Sort it manually 
    156 ;       ii = sort(a) & b = a(ii) 
     156;       ii = sort(a) & b = a[ii] 
    157157;       if keyword_set(non) then wh = where(b EQ shift(b, sh), ct) $ 
    158158;       else                     wh = where(b NE shift(b, sh), ct) 
    159 ;       if ct GT 0 then return, ii(wh) 
     159;       if ct GT 0 then return, ii[wh] 
    160160;   endif else begin 
    161161;       ;; Use the user's values directly 
     
    171171;; "first" value, whatever that may mean. 
    172172function cmset_op_uniq, a 
     173; 
     174  compile_opt idl2, strictarrsubs 
     175; 
    173176  if n_elements(a) LE 1 then return, 0L 
    174177 
    175   ii = sort(a) & b = a(ii) 
     178  ii = sort(a) & b = a[ii] 
    176179  wh = where(b NE shift(b, +1L), ct) 
    177   if ct GT 0 then return, ii(wh) 
     180  if ct GT 0 then return, ii[wh] 
    178181 
    179182  return, 0L 
     
    182185function cmset_op, a, op0, b, not1=not1, not2=not2, count=count, $ 
    183186              empty1=empty1, empty2=empty2, maxarray=ma, index=index 
     187; 
     188  compile_opt idl2, strictarrsubs 
     189; 
    184190 
    185191  on_error, 2 ;; return on error 
     
    204210  ;; Check the operation 
    205211  sz = size(op0) 
    206   if sz(sz(0)+1) NE 7 then begin 
     212  if sz[sz[0]+1] NE 7 then begin 
    207213      OP_ERR: 
    208214      message, "ERROR: OP must be 'AND', 'OR' or 'XOR'" 
     
    247253         if count GT 0 then return, a1 else return, -1L 
    248254     endif 
    249      if count GT 0 then return, a(a1) else return, -1L 
     255     if count GT 0 then return, a[a1] else return, -1L 
    250256     RET_B1: 
    251257     count = n2 
     
    253259         if count GT 0 then return, b1+n1 else return, -1L 
    254260     endif          
    255      if count GT 0 then return, b(b1) else return, -1L 
     261     if count GT 0 then return, b[b1] else return, -1L 
    256262 endif 
    257263 
     
    266272 
    267273  ;; Check types of operands 
    268   sz1 = size(a) & tp1 = sz1(sz1(0)+1) 
    269   sz2 = size(b) & tp2 = sz2(sz2(0)+1) 
     274  sz1 = size(a) & tp1 = sz1[sz1[0]+1] 
     275  sz2 = size(b) & tp2 = sz2[sz2[0]+1] 
    270276  if tp1 LT 0 OR tp1 GE 16 OR tp2 LT 0 OR tp2 GE 16 then begin 
    271277      message, 'ERROR: unrecognized data types for operands' 
    272278      return, -1 
    273279  endif 
    274   if basetype(tp1) NE basetype(tp2) then begin 
     280  if basetype[tp1] NE basetype[tp2] then begin 
    275281      TYPE1_ERR: 
    276282      message, 'ERROR: both A and B must be of the same type' 
     
    297303              count = n_elements(index0) 
    298304              if kind then return, index0 
    299               return, uu(index0) 
     305              return, uu[index0] 
    300306          end 
    301307 
     
    305311              bi = cmset_op_uniq(b) & nb = n_elements(bi) 
    306312              ui = [ai, bi+n1] 
    307               uu = [a,b]    & uu = uu(ui) ;; Raw union... 
    308               us = sort(uu) & uu = uu(us) ;; ...and sort 
    309               if kind then ui = ui(temporary(us)) else ui = 0 
     313              uu = [a,b]    & uu = uu[ui] ;; Raw union... 
     314              us = sort(uu) & uu = uu[us] ;; ...and sort 
     315              if kind then ui = ui[temporary(us)] else ui = 0 
    310316 
    311317              ;; Values in one set only will not have duplicates 
    312318              wh1 = where(uu NE shift(uu, -1), count1) 
    313319              if count1 EQ 0 then return, -1L 
    314               wh = where(wh1(1:*)-wh1 EQ 1, count) 
    315               if wh1(0) EQ 0 then begin 
     320              wh = where(wh1[1:*]-wh1 EQ 1, count) 
     321              if wh1[0] EQ 0 then begin 
    316322                  if count GT 0 then wh = [-1L, wh] else wh = [-1L] 
    317323                  count = n_elements(wh) 
    318324              endif 
    319325              if count EQ 0 then return, -1 
    320               if kind then return, ui(wh1(wh+1)) 
    321               return, uu(wh1(wh+1)) 
     326              if kind then return, ui[wh1[wh+1]] 
     327              return, uu[wh1[wh+1]] 
    322328          end 
    323329 
     
    327333              bi = cmset_op_uniq(b) & nb = n_elements(bi) 
    328334              ui = [ai, bi+n1] 
    329               uu = [a,b]    & uu = uu(ui)  ;; Raw union... 
    330               us = sort(uu) & uu = uu(us)  ;; ...and sort 
    331               if kind then ui = ui(us) else ui = 0 
     335              uu = [a,b]    & uu = uu[ui]  ;; Raw union... 
     336              us = sort(uu) & uu = uu[us]  ;; ...and sort 
     337              if kind then ui = ui[us] else ui = 0 
    332338 
    333339              if NOT keyword_set(not1) AND NOT keyword_set(not2) then begin 
     
    336342                  ;; they are equal, then the SHIFT() technique below 
    337343                  ;; fails.  Do this one by hand. 
    338                   if na EQ 1 AND nb EQ 1 AND uu(0) EQ uu(1) then begin 
     344                  if na EQ 1 AND nb EQ 1 AND uu[0] EQ uu[1] then begin 
    339345                      count = 1L 
    340346                      if kind then return, 0L 
    341                       return, [uu(0)] 
     347                      return, [uu[0]] 
    342348                  endif 
    343349 
     
    348354                  ;; This should always select the element from A 
    349355                  ;; rather than B (the smaller of the two) 
    350                   if kind then return, (ui(wh) < ui(wh+1)) 
    351                   return, uu(wh) 
     356                  if kind then return, (ui[wh] < ui[wh+1]) 
     357                  return, uu[wh] 
    352358              endif 
    353359 
    354360              ;; For "NOT" cases, we need to identify by set 
    355361              ii = make_array(na+nb, value=1b) 
    356               if keyword_set(not1) then ii(0:na-1) = 0 
    357               if keyword_set(not2) then ii(na:*)   = 0 
    358               ii = ii(temporary(us)) 
     362              if keyword_set(not1) then ii[0:na-1] = 0 
     363              if keyword_set(not2) then ii[na:*]   = 0 
     364              ii = ii[temporary(us)] 
    359365 
    360366              ;; Remove any duplicates 
    361367              wh1 = where(uu EQ shift(uu, -1L), count1) ;; Find non-unique 
    362               if count1 GT 0 then ii([wh1, wh1+1]) = 0 
     368              if count1 GT 0 then ii[wh1, wh1+1] = 0 
    363369              ;; Remainder is the desired set 
    364370              wh = where(ii, count) 
    365371              if count EQ 0 then return, -1L 
    366               if kind then return, ui(wh) 
    367               return, uu(wh) 
     372              if kind then return, ui[wh] 
     373              return, uu[wh] 
    368374          end 
    369375 
     
    380386      minn = min1 < min2 & maxx = max1 > max2 
    381387      nbins = maxx-minn+1 
    382       if (maxx-minn) GT floor(ma(0)) then goto, SLOW_SET_OP 
     388      if (maxx-minn) GT floor(ma[0]) then goto, SLOW_SET_OP 
    383389 
    384390      ;; Work around a stupidity in the built-in IDL HISTOGRAM routine 
     
    405411      result = temporary(wh+minn) 
    406412      if tp1 NE tp2 then return, result 
    407       szr = size(result) & tpr = szr(szr(0)+1) 
     413      szr = size(result) & tpr = szr[szr[0]+1] 
    408414 
    409415      ;; Cast to the original type if necessary 
    410416      if tpr NE tp1 then begin 
    411417          fresult = make_array(n_elements(result), type=tp1) 
    412           fresult(0) = temporary(result) 
     418          fresult[0] = temporary(result) 
    413419          result = temporary(fresult) 
    414420      endif 
     
    424430;     works, but is complicated, so I forced it to go to SLOW_SET_OP. 
    425431;     ha = histogram(a, min=minn, max=maxx, reverse=ra) < 1 
    426 ;     rr = ra(0:nbins) & mask = rr NE rr(1:*) & ra = ra(rr)*mask-1L+mask 
     432;     rr = ra[0:nbins] & mask = rr NE rr[1:*] & ra = ra[rr]*mask-1L+mask 
    427433;     hb = histogram(b, min=minn, max=maxx, reverse=rb) < 1 
    428 ;     rr = rb(0:nbins) & mask = rr NE rr(1:*) & rb = rb(rr)*mask-1L+mask 
     434;     rr = rb[0:nbins] & mask = rr NE rr[1:*] & rb = rb[rr]*mask-1L+mask 
    429435;     ...  AND/OR/XOR NOT masking here ... 
    430 ;     ra = ra(wh) & rb = rb(wh) 
     436;     ra = ra[wh] & rb = rb[wh] 
    431437;     return, ra*(ra GE 0) + (rb+n1)*(ra LT 0) ;; is last 'ra' right? 
    432438 
Note: See TracChangeset for help on using the changeset viewer.