Changeset 7999 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Jul 27, 2006, 2:44:05 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r7991 r7999 16 16 * use ->min and ->max (PS_STAT_USE_RANGE) 17 17 * 18 * @version $Revision: 1.18 1$ $Name: not supported by cvs2svn $19 * @date $Date: 2006-07-2 7 03:51:13$18 * @version $Revision: 1.182 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2006-07-28 00:44:05 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 /*****************************************************************************/ 35 35 #include "psMemory.h" 36 #include "psAbort.h" 36 37 #include "psImage.h" 37 38 #include "psVector.h" … … 80 81 81 82 // None 82 83 /*****************************************************************************/84 /* FUNCTION IMPLEMENTATION - LOCAL */85 /*****************************************************************************/86 87 psBool p_psGetStatValue(const psStats* stats, psF64 *value)88 {89 psTrace(__func__, 4, "---- %s() begin ----\n", __func__);90 // switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {91 switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {92 case PS_STAT_SAMPLE_MEAN:93 *value = stats->sampleMean;94 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);95 return true;96 97 case PS_STAT_SAMPLE_MEDIAN:98 *value = stats->sampleMedian;99 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);100 return true;101 102 case PS_STAT_SAMPLE_STDEV:103 *value = stats->sampleStdev;104 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);105 return true;106 107 case PS_STAT_ROBUST_MEDIAN:108 *value = stats->robustMedian;109 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);110 return true;111 112 case PS_STAT_ROBUST_STDEV:113 *value = stats->robustStdev;114 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);115 return true;116 117 case PS_STAT_CLIPPED_MEAN:118 *value = stats->clippedMean;119 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);120 return true;121 122 case PS_STAT_CLIPPED_STDEV:123 *value = stats->clippedStdev;124 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);125 return true;126 127 case PS_STAT_MAX:128 *value = stats->max;129 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);130 return true;131 132 case PS_STAT_MIN:133 *value = stats->min;134 psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);135 return true;136 137 default:138 psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);139 return false;140 }141 }142 83 143 84 /****************************************************************************** … … 2211 2152 return psStatsOptionToString(stats->options); 2212 2153 } 2154 2155 inline psStatsOptions psStatsSingleOption(psStatsOptions option) 2156 { 2157 switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) { 2158 case PS_STAT_SAMPLE_MEAN: 2159 case PS_STAT_SAMPLE_MEDIAN: 2160 case PS_STAT_SAMPLE_STDEV: 2161 case PS_STAT_SAMPLE_QUARTILE: 2162 case PS_STAT_ROBUST_MEDIAN: 2163 case PS_STAT_ROBUST_STDEV: 2164 case PS_STAT_ROBUST_QUARTILE: 2165 case PS_STAT_FITTED_MEAN: 2166 case PS_STAT_FITTED_STDEV: 2167 case PS_STAT_CLIPPED_MEAN: 2168 case PS_STAT_CLIPPED_STDEV: 2169 case PS_STAT_MAX: 2170 case PS_STAT_MIN: 2171 return option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE); 2172 default: 2173 return 0; 2174 } 2175 psAbort(__func__, "Should never get here.\n"); 2176 return 0; 2177 } 2178 2179 inline double psStatsGetValue(const psStats *stats, psStatsOptions option) 2180 { 2181 // We could call psStatsSingle to check, but it would be a waste since we effectively do it anyway 2182 switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) { 2183 case PS_STAT_SAMPLE_MEAN: 2184 return stats->sampleMean; 2185 case PS_STAT_SAMPLE_MEDIAN: 2186 return stats->sampleMedian; 2187 case PS_STAT_SAMPLE_STDEV: 2188 return stats->sampleStdev; 2189 case PS_STAT_ROBUST_MEDIAN: 2190 return stats->robustMedian; 2191 case PS_STAT_ROBUST_STDEV: 2192 return stats->robustStdev; 2193 case PS_STAT_FITTED_MEAN: 2194 return stats->fittedMean; 2195 case PS_STAT_FITTED_STDEV: 2196 return stats->fittedStdev; 2197 case PS_STAT_CLIPPED_MEAN: 2198 return stats->clippedMean; 2199 case PS_STAT_CLIPPED_STDEV: 2200 return stats->clippedStdev; 2201 case PS_STAT_MAX: 2202 return stats->max; 2203 case PS_STAT_MIN: 2204 return stats->min; 2205 case PS_STAT_SAMPLE_QUARTILE: 2206 case PS_STAT_ROBUST_QUARTILE: 2207 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot return a single quartile value; " 2208 "get them yourself.\n"); 2209 return NAN; 2210 default: 2211 return NAN; 2212 } 2213 psAbort(__func__, "Should never get here.\n"); 2214 return NAN; 2215 }
Note:
See TracChangeset
for help on using the changeset viewer.
