Changeset 1779 for branches/mergetest/src/MathUtils.cpp
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/src/MathUtils.cpp
r1570 r1779 38 38 #include <casa/BasicSL/String.h> 39 39 #include <scimath/Mathematics/MedianSlider.h> 40 #include <casa/Exceptions/Error.h> 40 41 41 42 #include <scimath/Fitting/LinearFit.h> … … 53 54 String str(which); 54 55 str.upcase(); 55 if (str. contains(String("MIN"))) {56 if (str.matches(String("MIN"))) { 56 57 return min(data); 57 } else if (str. contains(String("MAX"))) {58 } else if (str.matches(String("MAX"))) { 58 59 return max(data); 59 } else if (str. contains(String("SUMSQ"))) {60 } else if (str.matches(String("SUMSQ"))) { 60 61 return sumsquares(data); 61 } else if (str. contains(String("SUM"))) {62 } else if (str.matches(String("SUM"))) { 62 63 return sum(data); 63 } else if (str. contains(String("MEAN"))) {64 } else if (str.matches(String("MEAN"))) { 64 65 return mean(data); 65 } else if (str. contains(String("VAR"))) {66 } else if (str.matches(String("VAR"))) { 66 67 return variance(data); 67 } else if (str.contains(String("STDDEV"))) {68 } else if (str.matches(String("STDDEV"))) { 68 69 return stddev(data); 69 } else if (str. contains(String("AVDEV"))) {70 } else if (str.matches(String("AVDEV"))) { 70 71 return avdev(data); 71 } else if (str. contains(String("RMS"))) {72 } else if (str.matches(String("RMS"))) { 72 73 uInt n = data.nelementsValid(); 73 74 return sqrt(sumsquares(data)/n); 74 } else if (str. contains(String("MED"))) {75 } else if (str.matches(String("MEDIAN"))) { 75 76 return median(data); 76 } 77 } else { 78 String msg = str + " is not a valid type of statistics"; 79 throw(AipsError(msg)); 80 } 77 81 return 0.0; 78 82 } 79 83 84 IPosition mathutil::minMaxPos(const String& which, 85 const MaskedArray<Float>& data) 86 { 87 Float minVal, maxVal; 88 IPosition minPos(data.ndim(), 0), maxPos(data.ndim(), 0); 89 minMax(minVal, maxVal, minPos, maxPos, data); 90 String str(which); 91 str.upcase(); 92 if (str.contains(String("MIN"))) { 93 return minPos; 94 } else if (str.contains(String("MAX"))) { 95 return maxPos; 96 } else { 97 String msg = str + " is not a valid type of statistics"; 98 throw(AipsError(msg)); 99 } 100 //return 0.0; 101 } 80 102 81 103 void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask)
Note:
See TracChangeset
for help on using the changeset viewer.