- Timestamp:
- 02/16/05 12:26:03 (21 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
-
MathUtils.cc (modified) (1 diff)
-
MathUtils.h (modified) (1 diff)
-
MathUtils2.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MathUtils.cc
r382 r452 78 78 79 79 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 // 80 void mathutil::scanBoundaries(Vector<uInt>& startInt, 81 Vector<uInt>& endInt, 82 const Vector<Int>& scanIDs) 83 // Find integrations start and end for each Scan 86 84 { 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); 110 108 } -
trunk/src/MathUtils.h
r414 r452 59 59 void replaceMaskByZero(casa::Vector<casa::Float>& data, 60 60 const casa::Vector<casa::Bool>& mask); 61 62 // Extend the 63 template <class T> 64 void extendLastArrayAxis(casa::Array<T>& out, const casa::Array<T>& in, 65 const T& initVal); 66 61 67 }; 62 68 -
trunk/src/MathUtils2.cc
r364 r452 31 31 32 32 #include <casa/aips.h> 33 #include <casa/Arrays/Array.h> 34 #include <casa/Arrays/ArrayIter.h> 33 35 #include <casa/Arrays/Vector.h> 34 36 #include <casa/Arrays/VectorSTLIterator.h> … … 108 110 } 109 111 110 111 112 113 114 112 template <class T> 113 void 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.
