Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 7991)
+++ trunk/psLib/src/math/psStats.c	(revision 7999)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.181 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-07-27 03:51:13 $
+ *  @version $Revision: 1.182 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-28 00:44:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,5 @@
 /*****************************************************************************/
 #include "psMemory.h"
+#include "psAbort.h"
 #include "psImage.h"
 #include "psVector.h"
@@ -80,64 +81,4 @@
 
 // None
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - LOCAL                                           */
-/*****************************************************************************/
-
-psBool p_psGetStatValue(const psStats* stats, psF64 *value)
-{
-    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
-    //    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
-    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
-    case PS_STAT_SAMPLE_MEAN:
-        *value = stats->sampleMean;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_SAMPLE_MEDIAN:
-        *value = stats->sampleMedian;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_SAMPLE_STDEV:
-        *value = stats->sampleStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_ROBUST_MEDIAN:
-        *value = stats->robustMedian;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_ROBUST_STDEV:
-        *value = stats->robustStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_CLIPPED_MEAN:
-        *value = stats->clippedMean;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_CLIPPED_STDEV:
-        *value = stats->clippedStdev;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_MAX:
-        *value = stats->max;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    case PS_STAT_MIN:
-        *value = stats->min;
-        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
-        return true;
-
-    default:
-        psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
-        return false;
-    }
-}
 
 /******************************************************************************
@@ -2211,2 +2152,64 @@
     return psStatsOptionToString(stats->options);
 }
+
+inline psStatsOptions psStatsSingleOption(psStatsOptions option)
+{
+    switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
+    case PS_STAT_SAMPLE_MEAN:
+    case PS_STAT_SAMPLE_MEDIAN:
+    case PS_STAT_SAMPLE_STDEV:
+    case PS_STAT_SAMPLE_QUARTILE:
+    case PS_STAT_ROBUST_MEDIAN:
+    case PS_STAT_ROBUST_STDEV:
+    case PS_STAT_ROBUST_QUARTILE:
+    case PS_STAT_FITTED_MEAN:
+    case PS_STAT_FITTED_STDEV:
+    case PS_STAT_CLIPPED_MEAN:
+    case PS_STAT_CLIPPED_STDEV:
+    case PS_STAT_MAX:
+    case PS_STAT_MIN:
+        return option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE);
+    default:
+        return 0;
+    }
+    psAbort(__func__, "Should never get here.\n");
+    return 0;
+}
+
+inline double psStatsGetValue(const psStats *stats, psStatsOptions option)
+{
+    // We could call psStatsSingle to check, but it would be a waste since we effectively do it anyway
+    switch (option & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
+    case PS_STAT_SAMPLE_MEAN:
+        return stats->sampleMean;
+    case PS_STAT_SAMPLE_MEDIAN:
+        return stats->sampleMedian;
+    case PS_STAT_SAMPLE_STDEV:
+        return stats->sampleStdev;
+    case PS_STAT_ROBUST_MEDIAN:
+        return stats->robustMedian;
+    case PS_STAT_ROBUST_STDEV:
+        return stats->robustStdev;
+    case PS_STAT_FITTED_MEAN:
+        return stats->fittedMean;
+    case PS_STAT_FITTED_STDEV:
+        return stats->fittedStdev;
+    case PS_STAT_CLIPPED_MEAN:
+        return stats->clippedMean;
+    case PS_STAT_CLIPPED_STDEV:
+        return stats->clippedStdev;
+    case PS_STAT_MAX:
+        return stats->max;
+    case PS_STAT_MIN:
+        return stats->min;
+    case PS_STAT_SAMPLE_QUARTILE:
+    case PS_STAT_ROBUST_QUARTILE:
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot return a single quartile value; "
+                "get them yourself.\n");
+        return NAN;
+    default:
+        return NAN;
+    }
+    psAbort(__func__, "Should never get here.\n");
+    return NAN;
+}
