- Timestamp:
- 05/16/12 18:23:20 (13 years ago)
- Location:
- branches/hpc33/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/src/STIdxIter.cpp
r2524 r2533 10 10 namespace asap { 11 11 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 ) ; 12 IndexIterator::IndexIterator( IPosition &shape ) 13 : niter_m( 0 ) 14 { 15 nfield_m = shape.nelements() ; 19 16 prod_m = Block<uInt>( nfield_m, 1 ) ; 20 17 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 }28 18 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] ; 32 22 // 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 ;45 23 } 46 24 … … 64 42 ArrayIndexIterator::ArrayIndexIterator( Matrix<uInt> &arr, 65 43 vector< vector<uInt> > idlist ) 66 : arr_m( arr ) //,67 //pos_m( IPosition(1,0) )44 : arr_m( arr ), 45 pos_m( IPosition(1,0) ) 68 46 { 69 47 ncol_m = arr_m.ncolumn() ; 70 48 nrow_m = arr_m.nrow() ; 71 //storage_m.resize( nrow_m ) ;72 49 vector< vector<uInt> > l = idlist ; 73 50 if ( l.size() != ncol_m ) { … … 80 57 } 81 58 } 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 ) ; 83 66 } 84 67 … … 90 73 Vector<uInt> ArrayIndexIterator::current() 91 74 { 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 ; 93 79 } 94 80 … … 97 83 return iter_m->pastEnd() ; 98 84 } 99 100 // void ArrayIndexIterator::next()101 // {102 // iter_m->next() ;103 // }104 85 105 86 ArrayIndexIteratorNormal::ArrayIndexIteratorNormal( Matrix<uInt> &arr, 106 87 vector< vector<uInt> > idlist ) 107 : ArrayIndexIterator( arr, idlist ), 108 pos_m( IPosition( 1, 0 ) ) 88 : ArrayIndexIterator( arr, idlist ) 109 89 { 110 90 storage_m.resize( nrow_m ) ; … … 135 115 ArrayIndexIteratorAcc::ArrayIndexIteratorAcc( Matrix<uInt> &arr, 136 116 vector< vector<uInt> > idlist ) 137 : ArrayIndexIterator( arr, idlist ), 138 pos_m( IPosition(1) ) 117 : ArrayIndexIterator( arr, idlist ) 139 118 { 140 119 storage_m.resize( arr_m.nelements()+nrow_m ) ; … … 148 127 } 149 128 prev_m = current() - (uInt)1 ; 150 151 // test152 // cout << "row 21, col 2 " << arr_m( 21, 2 ) << endl ;153 129 } 154 130 … … 166 142 if ( c < 0 ) { 167 143 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 ) ; 169 145 } 170 146 uInt *base = storage_m.storage() + (c+1) * nrow_m ; … … 236 212 } 237 213 214 Vector<uInt> STIdxIter::getRows( StorageInitPolicy policy ) 215 { 216 return iter_m->getRows( policy ) ; 217 } 218 238 219 STIdxIterNormal::STIdxIterNormal() 239 220 : STIdxIter() -
branches/hpc33/src/STIdxIter.h
r2524 r2533 6 6 #include <casa/Arrays/Vector.h> 7 7 #include <casa/Arrays/Matrix.h> 8 #include <casa/Arrays/IPosition.h> 8 9 9 10 #include "Scantable.h" … … 16 17 { 17 18 public: 18 IndexIterator( vector< vector<uInt> > &idlist) ;19 Vector<uInt> current();19 IndexIterator( IPosition &shape ) ; 20 Block<uInt> current() { return idx_m ; } ; 20 21 Bool pastEnd() ; 21 22 void next() ; 22 23 private: 23 vector< vector<uInt> > idxlist_m ;24 24 uInt nfield_m ; 25 25 Block<uInt> prod_m ; … … 27 27 uInt niter_m ; 28 28 uInt maxiter_m ; 29 Vector<uInt> current_m ;30 29 } ; 31 30 … … 44 43 uInt nrow_m ; 45 44 uInt ncol_m ; 46 //Vector<uInt> storage_m ;45 Block<uInt> storage_m ; 47 46 Matrix<uInt> arr_m ; 48 //IPosition pos_m ; 47 IPosition pos_m ; 48 Vector<uInt> current_m ; 49 vector< vector<uInt> > idxlist_m ; 49 50 } ; 50 51 … … 56 57 void next() ; 57 58 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 ; 61 62 } ; 62 63 … … 73 74 74 75 Vector<uInt> prev_m ; 75 Block<uInt> storage_m ;76 IPosition pos_m ;76 // Block<uInt> storage_m ; 77 // IPosition pos_m ; 77 78 Block<uInt> len_m ; 78 79 } ; … … 92 93 void next() { iter_m->next() ; } ; 93 94 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 ) ; 95 96 protected: 96 97 ArrayIndexIterator *iter_m ;
Note:
See TracChangeset
for help on using the changeset viewer.