Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 2217)
+++ trunk/psLib/src/math/psStats.c	(revision 2220)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.75 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:55:09 $
 n *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1437,19 +1437,11 @@
 psHistogram* psHistogramAlloc(float lower, float upper, psS32 n)
 {
+    PS_INT_CHECK_POSITIVE(n, NULL);
+    PS_FLOAT_COMPARE(lower, upper, NULL);
+
     psS32 i = 0;                  // Loop index variable
     psHistogram* newHist = NULL;        // The new histogram structure
     float binSize = 0.0;        // The histogram bin size
 
-    // NOTE: Verify that this is the correct action.
-    if (n == 0) {
-        return (NULL);
-    }
-    if (n < 0) {
-        psAbort(__func__, "psHistogramAlloc() called with bin size %d.\n", n);
-    }
-    // NOTE: Verify that this is the correct action.
-    if (lower > upper) {
-        return (NULL);
-    }
     // Allocate memory for the new histogram structure.  If there are N
     // bins, then there are N+1 bounds to those bins.
@@ -1494,22 +1486,11 @@
 psHistogram* psHistogramAllocGeneric(const psVector* restrict bounds)
 {
+    PS_VECTOR_CHECK_NULL(bounds, NULL);
+    PS_VECTOR_CHECK_TYPE(bounds, PS_TYPE_F32, NULL);
+    PS_INT_COMPARE(bounds->n, 2, NULL);
+
     psHistogram* newHist = NULL;        // The new histogram structure
     psS32 i;                      // Loop index variable
 
-    // NOTE: Verify that this is the correct action.
-    if (bounds == NULL) {
-        // psAbort(__func__, "psHistogram requested with NULL bounds");
-        return (NULL);
-    }
-    // NOTE: Verify that this is the correct action.
-    if (bounds->n <= 1) {
-        // psAbort(__func__, "psHistogram requested with NULL bounds");
-        return (NULL);
-    }
-
-    if (bounds->type.type != PS_TYPE_F32) {
-        // psAbort(__func__, "psHistogram request a bound which is not type F32");
-        return (NULL);
-    }
     // Allocate memory for the new histogram structure.
     newHist = (psHistogram* ) psAlloc(sizeof(psHistogram));
@@ -1562,4 +1543,13 @@
                                psU32 maskVal)
 {
+    PS_PTR_CHECK_NULL(out, NULL);
+    PS_VECTOR_CHECK_TYPE(out->bounds, PS_TYPE_F32, NULL);
+    PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_U32, NULL);
+    PS_VECTOR_CHECK_NULL(in, NULL);
+    if (mask != NULL) {
+        PS_VECTOR_CHECK_SIZE_EQUAL(in, mask, NULL);
+        PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+    }
+
     psS32 i = 0;                  // Loop index variable
     float binSize = 0.0;        // Histogram bin size
@@ -1571,31 +1561,4 @@
     psVector* inF32;
     psS32 mustFreeTmp = 1;
-
-    // NOTE: Verify that this is the correct action.
-    if (out == NULL) {
-        return (NULL);
-    }
-    // Check the specified output histogram for type psF32
-    if (out->bounds->type.type != PS_TYPE_F32) {
-        psAbort(__func__, "Only data type PS_TYPE_F32 for the output.bounds member.");
-    }
-
-    if (out->nums->type.type != PS_TYPE_U32) {
-        psAbort(__func__, "Only data type PS_TYPE_U32 for out->nums member.");
-    }
-    // NOTE: Verify that this is the correct action.
-    if (in == NULL) {
-        return (out);
-    }
-
-    if (mask != NULL) {
-        if (in->n != mask->n) {
-            psError(__func__, "Vector data and vector mask are of different sizes.");
-        }
-        if (mask->type.type != PS_TYPE_U8) {
-            psError(__func__, "Vector mask must be type PS_TYPE_U8");
-        }
-    }
-
     inF32 = p_psConvertToF32((psVector *) in);
     if (inF32 == NULL) {
@@ -1721,12 +1684,12 @@
                        psU32 maskVal)
 {
+    PS_PTR_CHECK_NULL(stats, NULL);
+    PS_VECTOR_CHECK_NULL(in, NULL);
+    if (mask != NULL) {
+        PS_VECTOR_CHECK_SIZE_EQUAL(mask, in, NULL);
+        PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
+    }
     psVector* inF32;
     psS32 mustFreeTmp = 1;
-
-    if (in == NULL) {
-        psError(__func__, "in is NULL\n");
-        return(stats);
-    }
-    PS_PTR_CHECK_NULL(stats, NULL);
 
     inF32 = p_psConvertToF32((psVector *) in);
@@ -1735,13 +1698,9 @@
         mustFreeTmp = 0;
     }
+
     if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) {
-        psError(__func__, "psVectorStats() called with range: %f to %f\n", stats->min, stats->max);
-        return(stats);
-    }
-
-    if (mask != NULL) {
-        PS_VECTOR_CHECK_SIZE_EQUAL(mask, in, NULL);
-        PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
-    }
+        PS_FLOAT_COMPARE(stats->max, stats->min, stats);
+    }
+
     // ************************************************************************
     if (stats->options & PS_STAT_SAMPLE_MEAN) {
