Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 2269)
+++ trunk/psLib/src/math/psStats.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 03:30:30 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,6 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
 
 /*****************************************************************************/
@@ -735,13 +737,9 @@
 
     // Ensure that stats->clipIter is within the proper range.
-    if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) {
-        psError(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipIter,PS_CLIPPED_NUM_ITER_LB,PS_CLIPPED_NUM_ITER_UB,-1);
+
     // Ensure that stats->clipSigma is within the proper range.
-    if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) {
-        psError(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipSigma,PS_CLIPPED_SIGMA_LB,PS_CLIPPED_SIGMA_UB,-1);
+
     // We allocate a temporary mask vector since during the iterative
     // steps that follow, we will be masking off additional data points.
@@ -869,5 +867,9 @@
         p_psNormalizeVectorRangeF64(myData, low, high);
     } else {
-        psError(__func__, "Unalowable data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,myData->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_NOT_F32_F64,
+                strType);
     }
 }
@@ -954,6 +956,7 @@
         // Ensure that yVal is within the range of the bins we are using.
         if (!((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2]))) {
-            printf("((%f), %f, %f)\n", yVal, y->data.F64[0], y->data.F64[2]);
-            psError(__func__, "yVal not within y-range\n");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE,
+                    (double)yVal,y->data.F64[2],y->data.F64[0]);
         }
         yErr->data.F64[0] = 1.0;
@@ -1113,9 +1116,11 @@
 
     if ((LQBinNum < 0) || (UQBinNum < 0)) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
     if (medianBinNum < 0) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
@@ -1174,5 +1179,5 @@
     psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
 
-    p_psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
+    psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
     for (i=0;i<robustHistogramVector->n;i++) {
         myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
@@ -1536,5 +1541,9 @@
         // do nothing
     } else {
-        psError(__func__, "unsupported vector type 0x%x\n", in->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,in->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED,
+                strType);
     }
     return (tmp);
@@ -1603,5 +1612,6 @@
             (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
         if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorRobustStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psStats_STATS_FAILED);
         }
     }
@@ -1609,5 +1619,6 @@
     if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
         if (0 != p_psVectorClippedStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorClippedStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to calculate statistics for input psVector.");
         }
     }
