Changeset 452


Ignore:
Timestamp:
02/16/05 12:26:03 (19 years ago)
Author:
mar637
Message:
  • Added extendLastArrayAxis
Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MathUtils.cc

    r382 r452  
    7878
    7979
    80 void mathutil::scanBoundaries (Vector<uInt>& startInt,
    81                                Vector<uInt>& endInt,
    82                                const Vector<Int>& scanIDs)
    83 //
    84 // FInd integrations start and end for each Scan
    85 //
     80void mathutil::scanBoundaries(Vector<uInt>& startInt,
     81                              Vector<uInt>& endInt,
     82                              const Vector<Int>& scanIDs)
     83  // Find integrations start and end for each Scan
    8684{
    87    uInt nInt = scanIDs.nelements();
    88    startInt.resize(nInt);
    89    endInt.resize(nInt);
    90 //
    91    startInt(0) = 0;
    92    uInt j = 0;
    93    Int currScanID = scanIDs(0);
    94    for (uInt i=0; i<nInt; i++) {
    95       if (scanIDs(i) != currScanID) { 
    96          endInt(j) = i-1;
    97          currScanID = scanIDs(i);
    98 //
    99          j += 1;
    100          startInt(j) = i;
    101          if (i==nInt-1) {
    102             endInt(j) = i;
    103          }   
    104       } else {
    105          if (i==nInt-1) endInt(j) = i;
    106       }
    107    }
    108    startInt.resize(j+1,True);
    109    endInt.resize(j+1,True);
     85  uInt nInt = scanIDs.nelements();
     86  startInt.resize(nInt);
     87  endInt.resize(nInt);
     88
     89  startInt(0) = 0;
     90  uInt j = 0;
     91  Int currScanID = scanIDs(0);
     92  for (uInt i=0; i<nInt; i++) {
     93    if (scanIDs(i) != currScanID) { 
     94      endInt(j) = i-1;
     95      currScanID = scanIDs(i);
     96
     97      j += 1;
     98      startInt(j) = i;
     99      if (i==nInt-1) {
     100        endInt(j) = i;
     101      }   
     102    } else {
     103      if (i==nInt-1) endInt(j) = i;
     104    }
     105  }
     106  startInt.resize(j+1,True);
     107  endInt.resize(j+1,True);
    110108}
  • trunk/src/MathUtils.h

    r414 r452  
    5959void replaceMaskByZero(casa::Vector<casa::Float>& data,
    6060                        const casa::Vector<casa::Bool>& mask);
     61
     62// Extend the
     63template <class T>
     64void extendLastArrayAxis(casa::Array<T>& out, const casa::Array<T>& in,
     65                         const T& initVal);
     66
    6167};
    6268
  • trunk/src/MathUtils2.cc

    r364 r452  
    3131
    3232#include <casa/aips.h>
     33#include <casa/Arrays/Array.h>
     34#include <casa/Arrays/ArrayIter.h>
    3335#include <casa/Arrays/Vector.h>
    3436#include <casa/Arrays/VectorSTLIterator.h>
     
    108110}
    109111
    110 
    111  
    112 
    113 
    114 
     112template <class T>
     113void mathutil::extendLastArrayAxis(casa::Array<T>& out,
     114                                   const casa::Array<T>& in,
     115                                   const T& initVal)
     116{
     117 
     118  IPosition ipin = in.shape();
     119  IPosition ipout = ipin; // copy?
     120  // extend the axis by 1
     121  uInt axis = in.ndim()-1;
     122  ipout[axis] = ipin[axis]+1;
     123  out.resize(ipout);
     124  out = initVal;
     125  ArrayIterator<T> itout(out,axis);
     126  ReadOnlyArrayIterator<T> itin(in,axis);
     127  while ( !itin.pastEnd() ) {
     128    itout.array() = itin.array();  // copy vector by vector
     129    itin.next(); itout.next();
     130  }
     131}
Note: See TracChangeset for help on using the changeset viewer.