Changeset 2524 for branches


Ignore:
Timestamp:
05/15/12 19:00:13 (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...

Minor speedup of the code. Share memory between arrays as much as possible.


Location:
branches/hpc33/src
Files:
3 edited

Legend:

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

    r2519 r2524  
    116116}
    117117
    118 Vector<uInt> ArrayIndexIteratorNormal::getRows()
     118Vector<uInt> ArrayIndexIteratorNormal::getRows( StorageInitPolicy policy )
    119119{
    120120  Vector<uInt> v = current() ;
     
    130130  pos_m[0] = len ;
    131131  p = storage_m.storage() ;
    132   return Vector<uInt>( pos_m, p ) ;
     132  return Vector<uInt>( pos_m, p, policy ) ;
    133133}
    134134
     
    159159}
    160160
    161 Vector<uInt> ArrayIndexIteratorAcc::getRows()
     161Vector<uInt> ArrayIndexIteratorAcc::getRows( StorageInitPolicy policy )
    162162{
    163163  Vector<uInt> v = current() ;
     
    177177  }
    178178  pos_m[0] = len_m[0] ;
    179   return Vector<uInt>( pos_m, storage_m.storage() ) ;
     179  return Vector<uInt>( pos_m, storage_m.storage(), policy ) ;
    180180}
    181181
  • branches/hpc33/src/STIdxIter.h

    r2519 r2524  
    3939  Bool pastEnd() ;
    4040  virtual void next() = 0 ;
    41   virtual Vector<uInt> getRows() = 0 ;
     41  virtual Vector<uInt> getRows( StorageInitPolicy policy=COPY ) = 0 ;
    4242protected:
    4343  IndexIterator *iter_m ;
     
    5555                            vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
    5656  void next() ;
    57   Vector<uInt> getRows() ;
     57  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
    5858private:
    5959  Block<uInt> storage_m ;
     
    6767                         vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
    6868  void next() ;
    69   Vector<uInt> getRows() ;
     69  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
    7070private:
    7171  Int isChanged( Vector<uInt> &idx ) ;
     
    9292  void next() { iter_m->next() ; } ;
    9393  vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
    94   Vector<uInt> getRows() { return iter_m->getRows() ; } ;
     94  Vector<uInt> getRows( StorageInitPolicy policy=COPY ) { return iter_m->getRows( policy ) ; } ;
    9595protected:
    9696  ArrayIndexIterator *iter_m ;
  • branches/hpc33/src/STMath.cpp

    r2519 r2524  
    38613861  }
    38623862  else {
    3863 //     double t0 = mathutil::gettimeofday_sec() ;
     3863//     double t0, t1 ;
     3864//     t0 = mathutil::gettimeofday_sec() ;
    38643865    vector<bool> masks = s->getMask( 0 ) ;
    38653866   
     
    39043905      }
    39053906    }
    3906     //cout << "gaplist = " << gaplist << endl ;
     3907    gaplist[glidx] = nrow - 1 ;
     3908    glidx++ ;
     3909//     cout << "gaplist = " << Vector<uInt>(IPosition(1,glidx),gaplist.storage()) << endl ;
    39073910    uInt newid = 0 ;
    3908     for ( uInt i = 0 ; i < nrow ; i++ ) {
    3909       soff->scanCol_.put( i, newid ) ;
    3910       if ( i == gaplist[newid] ) {
    3911         newid++ ;
    3912       }
    3913     }
    3914     //cout << "new scancol = " << scanCol.getColumn() << endl ;
     3911    Vector<uInt> newscanno( nrow, 0 ) ;
     3912    uInt *p = newscanno.data() ;
     3913    IPosition pos( 1 ) ;
     3914    for ( uInt i = 1 ; i < glidx  ; i++ ) {
     3915      pos[0] = gaplist[i] - gaplist[i-1] ;
     3916      Vector<uInt> scnslice( pos, p+gaplist[i-1]+1, SHARE ) ;
     3917      scnslice = i ;
     3918    }
     3919    soff->scanCol_.putColumn( newscanno ) ;
     3920//     cout << "new scancol = " << soff->scanCol_.getColumn() << endl ;
     3921//     double t2 = mathutil::gettimeofday_sec() ;
    39153922    vector< CountedPtr<Scantable> > tmp( 1, soff ) ;
    39163923    CountedPtr<Scantable> aoff = average( tmp, masks, "TINT", "SCAN" ) ;
     3924//     cout << "elapsed time for average(): " << mathutil::gettimeofday_sec()-t2 << " sec" << endl ;
    39173925    //cout << "aoff.nrow = " << aoff->nrow() << endl ;
    39183926    s->unsetSelection() ;
    39193927    sel.reset() ;
    3920     //types.clear() ;
    3921 //     double t1 = mathutil::gettimeofday_sec() ;
     3928//     t1 = mathutil::gettimeofday_sec() ;
    39223929//     cout << "elapsed time for off averaging: " << t1-t0 << " sec" << endl ;
    39233930   
     
    39283935    CountedPtr<Scantable> out = getScantable( s, true ) ;
    39293936    insitu_ = insitu ;
    3930     //types.push_back( SrcType::PSON ) ;
    39313937    types[0] = SrcType::PSON ;
    39323938    sel.setTypes( types ) ;
     
    39353941    s->unsetSelection() ;
    39363942    sel.reset() ;
    3937     //types.clear() ;
    39383943//     t1 = mathutil::gettimeofday_sec() ;
    39393944//     cout << "elapsed time for preparing output table: " << t1-t0 << " sec" << endl ;
     
    39613966      sel.setTaQL( ss.str() ) ;
    39623967      aoff->setSelection( sel ) ;
    3963       Vector<uInt> rows = iter->getRows() ;
     3968      Vector<uInt> rows = iter->getRows( SHARE ) ;
    39643969      calibrateALMA( out, aoff, rows ) ;
    39653970      aoff->unsetSelection() ;
     
    46154620//         double tref = getMJD( reftime ) ;
    46164621        double tref = reftime ;
    4617         vector<float> sp0 = s->getSpectrum( idx[0] ) ;
     4622        sp = s->getSpectrum( idx[0] ) ;
    46184623        vector<float> sp1 = s->getSpectrum( idx[1] ) ;
    4619         sp.resize( sp0.size() ) ;
    4620         for ( unsigned int i = 0 ; i < sp0.size() ; i++ ) {
    4621           sp[i] = ( sp1[i] - sp0[i] ) / ( t1 - t0 ) * ( tref - t0 ) + sp0[i] ;
     4624        double tfactor = ( tref - t0 ) / ( t1 - t0 ) ;
     4625        for ( unsigned int i = 0 ; i < sp.size() ; i++ ) {
     4626          sp[i] = ( sp1[i] - sp[i] ) * tfactor + sp[i] ;
    46224627        }
    46234628      }
Note: See TracChangeset for help on using the changeset viewer.