Ignore:
Timestamp:
05/29/12 11:24:15 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Clean up code.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/src/STIdxIter.cpp

    r2548 r2550  
    1616  prod_m.resize( nfield_m ) ;
    1717  idx_m.resize( nfield_m ) ;
    18 //   prod_m[0] = 1 ;
    19 //   idx_m[0] = 0 ;
    20 //   for ( uInt i = 1 ; i < nfield_m ; i++ ) {
    21 //     prod_m[i] = shape[i-1] * prod_m[i-1] ;
    22 //     idx_m[i] = 0 ;
    23 //   }
    24 //   maxiter_m = prod_m[nfield_m-1] * shape[nfield_m-1] ;
    2518  prod_m[nfield_m-1] = 1 ;
    2619  idx_m[nfield_m-1] = 0 ;
     
    4235  niter_m++ ;
    4336  uInt x = niter_m ;
    44 //   for ( Int i = nfield_m-1 ; i >= 0 ; i-- ) {
    4537  for ( Int i = 0 ; i < nfield_m ; i++ ) {
    4638    idx_m[i] = x / prod_m[i] ;
     
    136128  // ...
    137129  storage_m.resize( arr_m.nelements()+nrow_m ) ;
    138 //   uInt *p = storage_m.storage() + arr_m.nelements() ;
     130  // initialize constant temporary storage
    139131  uInt *p = storage_m.storage() ;
    140132  for ( uInt i = 0 ; i < nrow_m ; i++ ) {
     
    142134    p++ ;
    143135  }
     136  // len_m layout
     137  // len[0]: length of temporary storage that incidates whole rows (constant)
     138  // len[1]: number of matched row for column 0 selection
     139  // len[2]: number of matched row for column 1 selection
     140  // ...
    144141  len_m.resize( ncol_m+1 ) ;
    145142  p = len_m.storage() ;
     
    149146//     cout << "len[" << i << "]=" << len_m[i] << endl ;
    150147  }
     148  // skip_m layout
     149  // skip_m[0]: True if column 0 is filled by unique value
     150  // skip_m[1]: True if column 1 is filled by unique value
     151  // ...
     152  skip_m.resize( ncol_m ) ;
     153  for ( uInt i = 0 ; i < ncol_m ; i++ ) {
     154    skip_m[i] = (Bool)(idxlist_m[i].size()==1) ;
     155//     cout << "skip_m[" << i << "]=" << skip_m[i] << endl ;
     156  }
    151157  prev_m = iter_m->current() ;
    152158  p = prev_m.storage() ;
     
    156162  }
    157163//   cout << "prev_m=" << Vector<uInt>(IPosition(1,ncol_m),prev_m.storage()) << endl ;
    158   skip_m.resize( ncol_m ) ;
    159   for ( uInt i = 0 ; i < ncol_m ; i++ ) {
    160     skip_m[i] = (Bool)(idxlist_m[i].size()==1) ;
    161 //     cout << "skip_m[" << i << "]=" << skip_m[i] << endl ;
    162   }
    163164}
    164165
     
    175176//   cout << "v=" << Vector<uInt>(IPosition(1,v.nelements()),v.storage(),SHARE) << endl ;
    176177//   cout << "c=" << c << endl ;
    177 //   if ( c < 0 ) {
    178178  if ( c > ncol_m-1 ) {
    179 //     pos_m[0] = len_m[0] ;
    180 //     uInt offset = 0 ;
    181 //     while( offset < ncol_m && skip_m[offset] )
    182 //       offset++ ;
    183179    pos_m[0] = len_m[ncol_m] ;
    184180    Int offset = ncol_m - 1 ;
     
    189185    return Vector<uInt>( pos_m, storage_m.storage()+offset*nrow_m, policy ) ;
    190186  }
    191 //   Int offset = c + 1 ;
    192 //   while( offset < ncol_m && skip_m[offset] )
    193 //     offset++ ;
    194187  Int offset = c - 1 ;
    195188  while( offset >= 0 && skip_m[offset] )
     
    200193//   cout << "len_m[c+1]=" << len_m[c+1] << endl ;
    201194//   cout << "base=" << Vector<uInt>(IPosition(1,len_m[c+1]),base,SHARE) << endl ;
    202 //   for ( Int i = c ; i >= 0 ; i-- ) {
    203 //     base = updateStorage( i, base, idxlist_m[i][v[i]] ) ;
    204   for ( Int i = c+1 ; i <= ncol_m ; i++ ) {
    205     base = updateStorage( i, base, idxlist_m[i-1][v[i-1]] ) ;
     195  for ( Int i = c ; i < ncol_m ; i++ ) {
     196    base = updateStorage( i, base, idxlist_m[i][v[i]] ) ;
    206197//     cout << "len_m[" << i << "]=" << len_m[i] << endl ;
    207198//     cout << "base=" << Vector<uInt>(IPosition(1,len_m[i]),base,SHARE) << endl ;
    208199  }
    209 //   pos_m[0] = len_m[0] ;
    210200  pos_m[0] = len_m[ncol_m] ;
    211201//   cout << "pos_m=" << pos_m << endl ;
     
    216206Int ArrayIndexIteratorAcc::isChanged( Block<uInt> &idx )
    217207{
    218 //   Int i = ncol_m - 1 ;
    219 //   while( i >= 0 && idx[i] == prev_m[i] )
    220 //     i-- ;
    221208  Int i = 0 ;
    222209  while( i < ncol_m && idx[i] == prev_m[i] )
     
    229216                                            uInt &v )
    230217{
     218  // CAUTION:
     219  // indexes for storage_m and len_m differ from index for skip_m by 1
     220  // (skip_m[0] corresponds to storage_m[1] and len_m[1]) since there
     221  // is additional temporary storage at first segment in storage_m
    231222  uInt *p ;
    232 //   if ( skip_m[icol] ) {
    233   if ( skip_m[icol-1] ) {
     223  if ( skip_m[icol] ) {
    234224    // skip update, just update len_m[icol] and pass appropriate pointer
    235225//     cout << "skip " << icol << endl ;
    236226    p = base ;
    237 //     len_m[icol] = len_m[icol+1] ;
    238     len_m[icol] = len_m[icol-1] ;
     227    len_m[icol+1] = len_m[icol] ;
    239228  }
    240229  else {
    241230//     cout << "update " << icol << endl ;
    242231    uInt len = 0 ;
    243     p = storage_m.storage() + icol * nrow_m ;
     232    p = storage_m.storage() + (icol+1) * nrow_m ;
    244233    uInt *work = p ;
    245234    Bool b ;
     
    247236    long offset = 0 ;
    248237    // warr_p points a first element of (icol)-th column
    249 //     const uInt *warr_p = arr_p + icol * nrow_m ;
    250     const uInt *warr_p = arr_p + (icol-1) * nrow_m ;
    251 //     for ( uInt i = 0 ; i < len_m[icol+1] ; i++ ) {
    252     for ( uInt i = 0 ; i < len_m[icol-1] ; i++ ) {
     238    const uInt *warr_p = arr_p + icol * nrow_m ;
     239    for ( uInt i = 0 ; i < len_m[icol] ; i++ ) {
    253240      // increment warr_p by (*(base)-*(base-1))
    254241      warr_p += *base - offset ;
     
    267254    }
    268255    arr_m.freeStorage( arr_p, b ) ;
    269     len_m[icol] = len ;
     256    len_m[icol+1] = len ;
    270257  }
    271258  return p ;
     
    464451{
    465452  convertArray( out, in ) ;
    466   //uInt len = in.nelements() ;
    467   //Vector<Int> tmp = in.copy() ;
    468   //uInt n = genSort( tmp, Sort::Ascending, Sort::QuickSort|Sort::NoDuplicates ) ;
    469   //val.resize( n ) ;
    470   //for ( uInt i = 0 ; i < n ; i++ ) {
    471   //  val[i] = tmp[i] ;
    472 //     cout << "val[" << i << "]=" << val[i] << endl ;
    473   //}
    474   //out.resize( len ) ;
    475   //uInt idx = -1 ;
    476   //cout << "idx=" << idx << endl ;
    477   //int idx2 = (Int)idx ;
    478   //cout << "idx2=" << idx2 << endl ;
    479   //idx = (uInt) idx2 ;
    480   //cout << "idx=" << idx << endl ;
    481   //if ( n == 1 ) {
    482   //  cout << "n=1" << endl ;
    483   //  out = 0 ;
    484   //}
    485   //else if ( n == 2 ) {
    486   //  cout << "n=2" << endl ;
    487   //  for ( uInt i = 0 ; i < len ; i++ ) {
    488   //    out[i] = (in[i] == val[0]) ? 0 : 1 ;
    489   //  }
    490   //}
    491   //else {
    492   //  cout << "n=" << n << endl ;
    493   //  map<Int,uInt> m ;
    494   // for( uInt i = 0 ; i < n ; i++ )
    495   //    m[val[i]] = i ;
    496   // for ( uInt i = 0 ; i < len ; i++ ) {
    497      //for ( uInt j = 0 ; j < n ; j++ ) {
    498       //  if ( in[i] == val[j] ) {
    499       //    out[i] = j ;
    500       //    break ;
    501       //  }
    502       //}
    503   //    out[i] = m[in[i]] ;
    504   //  }
    505   // }
    506453}
    507454
     
    518465//     cout << "val[" << i << "]=" << val[i] << endl ;
    519466  }
    520   //out.resize( len ) ;
    521467  if ( n == 1 ) {
    522468    //cout << "n=1" << endl ;
     
    535481      m[val[i]] = i ;
    536482    for ( uInt i = 0 ; i < len ; i++ ) {
    537       //for ( uInt j = 0 ; j < n ; j++ ) {
    538       //  if ( in[i] == val[j] ) {
    539       //    out[i] = j ;
    540       //    break ;
    541       //  }
    542       //}
    543483      out[i] = m[in[i]] ;
    544484    }
     
    548488Int STIdxIterExAcc::getSrcType()
    549489{
    550   //if ( srctype_m.nelements() > 0 )
    551490  if ( srctypeid_m >= 0 )
    552     //return srctype_m[iter_m->current()[srctypeid_m]] ;
    553491    return (Int)(iter_m->current()[srctypeid_m]) ;
    554492  else
Note: See TracChangeset for help on using the changeset viewer.