Changeset 2533 for branches


Ignore:
Timestamp:
05/16/12 18:23:20 (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...

Changed structure of ArrayIndexIterator?.
Index list, which was the attribute of IndexIterator? before, is now
belonging to ArrayIndexIterator?.


Location:
branches/hpc33/src
Files:
2 edited

Legend:

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

    r2524 r2533  
    1010namespace asap {
    1111
    12 IndexIterator::IndexIterator( vector< vector<uInt> > &idxlist )
    13   : idxlist_m( idxlist ),
    14     niter_m( 0 )
    15 {
    16   nfield_m = idxlist_m.size() ;
    17 //   cout << "nfield_m=" << nfield_m << endl ;
    18   Block<uInt> nidx( nfield_m ) ;
     12IndexIterator::IndexIterator( IPosition &shape )
     13  : niter_m( 0 )
     14{
     15  nfield_m = shape.nelements() ;
    1916  prod_m = Block<uInt>( nfield_m, 1 ) ;
    2017  idx_m = Block<uInt>( nfield_m, 0 ) ;
    21   current_m = Vector<uInt>( nfield_m ) ;
    22 //   cout << "idx_m.size()=" << idx_m.size() << endl ;
    23   for ( uInt i = 0 ; i < nfield_m ; i++ ) {
    24 //     cout << "idx_m[" << i << "]=" << idx_m[i] << endl ;
    25     nidx[i] = idxlist_m[i].size() ;
    26     current_m[i] = idxlist_m[i][idx_m[i]] ;
    27   }
    2818  for ( uInt i = 1 ; i < nfield_m ; i++ ) {
    29     prod_m[i] = nidx[i-1] * prod_m[i-1] ;
    30   }
    31   maxiter_m =prod_m[nfield_m-1] * nidx[nfield_m-1] ;
     19    prod_m[i] = shape[i-1] * prod_m[i-1] ;
     20  }
     21  maxiter_m = prod_m[nfield_m-1] * shape[nfield_m-1] ;
    3222//   cout << "maxiter_m=" << maxiter_m << endl ;
    33 }
    34 
    35 Vector<uInt> IndexIterator::current()
    36 {
    37   uInt *v = current_m.data() ;
    38   uInt *p = idx_m.storage() ;
    39   for ( uInt i = 0 ; i < nfield_m ; i++ ) {
    40     *v = idxlist_m[i][*p] ;
    41     v++ ;
    42     p++ ;
    43   }
    44   return current_m ;
    4523}
    4624
     
    6442ArrayIndexIterator::ArrayIndexIterator( Matrix<uInt> &arr,
    6543                                        vector< vector<uInt> > idlist )
    66   : arr_m( arr )//,
    67                                       //    pos_m( IPosition(1,0) )
     44  : arr_m( arr ),
     45    pos_m( IPosition(1,0) )
    6846{
    6947  ncol_m = arr_m.ncolumn() ;
    7048  nrow_m = arr_m.nrow() ;
    71   //storage_m.resize( nrow_m ) ;
    7249  vector< vector<uInt> > l = idlist ;
    7350  if ( l.size() != ncol_m ) {
     
    8057    }
    8158  }
    82   iter_m = new IndexIterator( l ) ;
     59  idxlist_m = l ;
     60  IPosition shape( ncol_m ) ;
     61  for ( uInt i = 0 ; i < ncol_m ; i++ ) {
     62    shape[i] = idxlist_m[i].size() ;
     63  }
     64  iter_m = new IndexIterator( shape ) ;
     65  current_m.resize( ncol_m ) ;
    8366}
    8467
     
    9073Vector<uInt> ArrayIndexIterator::current()
    9174{
    92   return iter_m->current() ;
     75  Block<uInt> idx = iter_m->current() ;
     76  for ( uInt i = 0 ; i < ncol_m ; i++ )
     77    current_m[i] = idxlist_m[i][idx[i]] ;
     78  return current_m ;
    9379}
    9480
     
    9783  return iter_m->pastEnd() ;
    9884}
    99 
    100 // void ArrayIndexIterator::next()
    101 // {
    102 //   iter_m->next() ;
    103 // }
    10485
    10586ArrayIndexIteratorNormal::ArrayIndexIteratorNormal( Matrix<uInt> &arr,
    10687                                                    vector< vector<uInt> > idlist )
    107   : ArrayIndexIterator( arr, idlist ),
    108     pos_m( IPosition( 1, 0 ) )
     88  : ArrayIndexIterator( arr, idlist )
    10989{
    11090  storage_m.resize( nrow_m ) ;
     
    135115ArrayIndexIteratorAcc::ArrayIndexIteratorAcc( Matrix<uInt> &arr,
    136116                                              vector< vector<uInt> > idlist )
    137   : ArrayIndexIterator( arr, idlist ),
    138     pos_m( IPosition(1) )
     117  : ArrayIndexIterator( arr, idlist )
    139118{
    140119  storage_m.resize( arr_m.nelements()+nrow_m ) ;
     
    148127  }
    149128  prev_m = current() - (uInt)1 ;
    150 
    151   // test
    152 //   cout << "row 21, col 2 " << arr_m( 21, 2 ) << endl ; 
    153129}
    154130
     
    166142  if ( c < 0 ) {
    167143    pos_m[0] = len_m[0] ;
    168     return Vector<uInt>( pos_m, storage_m.storage() ) ;
     144    return Vector<uInt>( pos_m, storage_m.storage(), policy ) ;
    169145  }
    170146  uInt *base = storage_m.storage() + (c+1) * nrow_m ;
     
    236212}
    237213
     214Vector<uInt> STIdxIter::getRows( StorageInitPolicy policy )
     215{
     216  return iter_m->getRows( policy ) ;
     217}
     218
    238219STIdxIterNormal::STIdxIterNormal()
    239220  : STIdxIter()
  • branches/hpc33/src/STIdxIter.h

    r2524 r2533  
    66#include <casa/Arrays/Vector.h>
    77#include <casa/Arrays/Matrix.h>
     8#include <casa/Arrays/IPosition.h>
    89
    910#include "Scantable.h"
     
    1617{
    1718public:
    18   IndexIterator( vector< vector<uInt> > &idlist ) ;
    19   Vector<uInt> current() ;
     19  IndexIterator( IPosition &shape ) ;
     20  Block<uInt> current() { return idx_m ; } ;
    2021  Bool pastEnd() ;
    2122  void next() ;
    2223private:
    23   vector< vector<uInt> > idxlist_m ;
    2424  uInt nfield_m ;
    2525  Block<uInt> prod_m ;
     
    2727  uInt niter_m ;
    2828  uInt maxiter_m ;
    29   Vector<uInt> current_m ;
    3029} ;
    3130
     
    4443  uInt nrow_m ;
    4544  uInt ncol_m ;
    46   //Vector<uInt> storage_m ;
     45  Block<uInt> storage_m ;
    4746  Matrix<uInt> arr_m ;
    48   //IPosition pos_m ;
     47  IPosition pos_m ;
     48  Vector<uInt> current_m ;
     49  vector< vector<uInt> > idxlist_m ;
    4950} ;
    5051
     
    5657  void next() ;
    5758  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
    58 private:
    59   Block<uInt> storage_m ;
    60   IPosition pos_m ;
     59// private:
     60//   Block<uInt> storage_m ;
     61//   IPosition pos_m ;
    6162} ;
    6263
     
    7374
    7475  Vector<uInt> prev_m ;
    75   Block<uInt> storage_m ;
    76   IPosition pos_m ;
     76//   Block<uInt> storage_m ;
     77//   IPosition pos_m ;
    7778  Block<uInt> len_m ;
    7879} ;
     
    9293  void next() { iter_m->next() ; } ;
    9394  vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
    94   Vector<uInt> getRows( StorageInitPolicy policy=COPY ) { return iter_m->getRows( policy ) ; } ;
     95  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
    9596protected:
    9697  ArrayIndexIterator *iter_m ;
Note: See TracChangeset for help on using the changeset viewer.