Changeset 2369


Ignore:
Timestamp:
12/14/11 18:13:54 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2816

Ready for Test: No

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...

Gridding speed up: direct array access using getStorage()

in STGrid::getWeight().


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2368 r2369  
    550550  else if ( wtype_.compare( "TINT" ) == 0 ) {
    551551    if ( npol_ > 1 ) warn = True ;
     552    Bool b0, b1 ;
     553    Float *w_p = w.getStorage( b0 ) ;
     554    Float *w0_p = w_p ;
     555    const Double *ti_p = tint.getStorage( b1 ) ;
     556    const Double *w1_p = ti_p ;
    552557    for ( Int irow = 0 ; irow < nrow_ ; irow++ ) {
    553       Float val = mean( tint.column( irow ) ) ;
    554       w.column( irow ) = val ;
    555     }
     558      Float val = (Float)(polMean( w1_p )) ;
     559      for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) {
     560        *w0_p = val ;
     561        w0_p++ ;
     562      }
     563    }
     564    w.putStorage( w_p, b0 ) ;
     565    tint.freeStorage( ti_p, b1 ) ;
    556566  }
    557567  else if ( wtype_.compare( "TSYS" ) == 0 ) {
    558568    if ( npol_ > 1 ) warn = True ;
     569    Bool b0, b1 ;
     570    Float *w_p = w.getStorage( b0 ) ;
     571    Float *w0_p = w_p ;
     572    const Float *ts_p = tsys.getStorage( b1 ) ;
     573    const Float *w1_p = ts_p ;
    559574    for ( Int irow = 0 ; irow < nrow_ ; irow++ ) {
    560       Matrix<Float> arr = tsys.xyPlane( irow ) ;
    561575      for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) {
    562         Float val = mean( arr.column( ichan ) ) ;
    563         w(ichan,irow) = 1.0 / ( val * val ) ;
     576        Float val = polMean( w1_p ) ;
     577        *w0_p = 1.0 / ( val * val ) ;
     578        w0_p++ ;
    564579      }
    565580    }
     581    w.putStorage( w_p, b0 ) ;
     582    tsys.freeStorage( ts_p, b1 ) ;
    566583  }
    567584  else if ( wtype_.compare( "TINTSYS" ) == 0 ) {
    568585    if ( npol_ > 1 ) warn = True ;
     586    Bool b0, b1, b2 ;
     587    Float *w_p = w.getStorage( b0 ) ;
     588    Float *w0_p = w_p ;
     589    const Double *ti_p = tint.getStorage( b1 ) ;
     590    const Double *w1_p = ti_p ;
     591    const Float *ts_p = tsys.getStorage( b2 ) ;
     592    const Float *w2_p = ts_p ;
    569593    for ( Int irow = 0 ; irow < nrow_ ; irow++ ) {
    570       Float interval = mean( tint.column( irow ) ) ;
    571       Matrix<Float> arr = tsys.xyPlane( irow ) ;
     594      Float interval = (Float)(polMean( w1_p )) ;
    572595      for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) {
    573         Float temp = mean( arr.column( ichan ) ) ;
    574         w(ichan,irow) = interval / ( temp * temp ) ;
     596        Float temp = polMean( w2_p ) ;
     597        *w0_p = interval / ( temp * temp ) ;
     598        w0_p++ ;
    575599      }
    576600    }
     601    w.putStorage( w_p, b0 ) ;
     602    tint.freeStorage( ti_p, b1 ) ;
     603    tsys.freeStorage( ts_p, b2 ) ;
    577604  }
    578605  else {
     
    588615  t1 = mathutil::gettimeofday_sec() ;
    589616  os << "getWeight: elapsed time is " << t1-t0 << " sec" << LogIO::POST ;
     617}
     618
     619Float STGrid::polMean( const Float *p )
     620{
     621  Float v = 0.0 ;
     622  for ( Int i = 0 ; i < npol_ ; i++ ) {
     623    v += *p ;
     624    p++ ;
     625  }
     626  v /= npol_ ;
     627  return v ;
     628}
     629
     630Double STGrid::polMean( const Double *p )
     631{
     632  Double v = 0.0 ;
     633  for ( Int i = 0 ; i < npol_ ; i++ ) {
     634    v += *p ;
     635    p++ ;
     636  }
     637  v /= npol_ ;
     638  return v ;
    590639}
    591640
  • trunk/src/STGrid.h

    r2368 r2369  
    108108  void selectData( Table &tab ) ;
    109109
     110  Float polMean( const Float *p ) ;
     111  Double polMean( const Double *p ) ;
     112
    110113  String infile_ ;
    111114  Int ifno_ ;
Note: See TracChangeset for help on using the changeset viewer.