Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 674)
+++ trunk/psLib/src/math/psStats.c	(revision 679)
@@ -166,5 +166,5 @@
     if (maskVector != NULL) {
         for (i=0;i<myVector->n;i++) {
-            if (!(maskVal & maskVector->vec.i32[i])) {
+            if (!(maskVal & maskVector->vec.ui8[i])) {
                 mean+= myVector->vec.f[i];
                 count++;
@@ -172,11 +172,10 @@
         }
         mean/= (float) count;
-        return(mean);
     } else {
         for (i=0;i<myVector->n;i++) {
             mean+= myVector->vec.f[i];
         }
-    }
-    mean/= myVector->n;
+        mean/= (float) myVector->n;
+    }
     return(mean);
 }
@@ -189,9 +188,10 @@
     float max = -1e99;
 
+    printf("COOL: p_psArrayMax()\n");
     if (maskVector != NULL) {
         for (i=0;i<myVector->n;i++) {
-            if (!(maskVal & maskVector->vec.i32[i])) {
+            if (!(maskVal & maskVector->vec.ui8[i])) {
                 if (myVector->vec.f[i] > max) {
-                    max = maskVector->vec.i32[i];
+                    max = myVector->vec.f[i];
                 }
             }
@@ -200,5 +200,5 @@
         for (i=0;i<myVector->n;i++) {
             if (myVector->vec.f[i] > max) {
-                max = maskVector->vec.i32[i];
+                max = myVector->vec.f[i];
             }
         }
@@ -216,7 +216,7 @@
     if (maskVector != NULL) {
         for (i=0;i<myVector->n;i++) {
-            if (!(maskVal & maskVector->vec.i32[i])) {
+            if (!(maskVal & maskVector->vec.ui8[i])) {
                 if (myVector->vec.f[i] < min) {
-                    min = maskVector->vec.i32[i];
+                    min = myVector->vec.f[i];
                 }
             }
@@ -225,5 +225,5 @@
         for (i=0;i<myVector->n;i++) {
             if (myVector->vec.f[i] < min) {
-                min = maskVector->vec.i32[i];
+                min = myVector->vec.f[i];
             }
         }
@@ -244,5 +244,5 @@
     if (maskVector != NULL) {
         for (i=0;i<myVector->n;i++) {
-            if (!(maskVal & maskVector->vec.i32[i])) {
+            if (!(maskVal & maskVector->vec.ui8[i])) {
                 numData++;
             }
@@ -277,5 +277,5 @@
         if (maskVector != NULL) {
             for (i=0;i<myVector->n;i++) {
-                if (!(maskVal & maskVector->vec.i32[i])) {
+                if (!(maskVal & maskVector->vec.ui8[i])) {
                     unsortedVector->vec.f[count++] = maskVector->vec.f[i];
                 }
@@ -319,6 +319,13 @@
 }
 
-psStats *psArrayStats(const psVector *restrict myVector, // FLOAT
-                      const psVector *restrict maskVector, // INT
+/******************************************************************************
+ 
+    NOTE: The current strategy is to implement everything assuming that all
+    input data is of type PS_TYPE_FLOAT.  Once the basic code is in place,
+    we will macro-ize everything and add PS_TYPE_UINT16 and PS_TYPE_DOUBLE.
+ 
+ *****************************************************************************/
+psStats *psArrayStats(const psVector *restrict myVector,
+                      const psVector *restrict maskVector,
                       unsigned int maskVal,
                       psStats *stats)
@@ -328,11 +335,22 @@
     newStruct = psStatsAlloc(stats->options);
     if (myVector == NULL) {
-        psError(__func__,
+        psAbort(__func__,
                 "Input data array (myVector) was NULL.");
     }
 
-    if ((maskVector != NULL) &&
-            (myVector->n != maskVector->n)) {
-        psError(__func__, "Vector data and vector mask are of different sizes.");
+    if (myVector->type.type != PS_TYPE_FLOAT) {
+        psAbort(__func__,
+                "Only data type PS_TYPE_FLOAT is currently supported.");
+    }
+
+    if (maskVector != NULL) {
+        if (myVector->n != maskVector->n) {
+            psAbort(__func__,
+                    "Vector data and vector mask are of different sizes.");
+        }
+        if (maskVector->type.type != PS_TYPE_UINT8) {
+            psAbort(__func__,
+                    "Vector mask must be type PS_TYPE_UINT8");
+        }
     }
 
@@ -426,5 +444,5 @@
     //    OLD CODE: Should we check for an unknown option?
     //    default:
-    //        psError(__func__, "Unknown options 0x%x.\n", stats->options);
+    //        psAbort(__func__, "Unknown options 0x%x.\n", stats->options);
 
     return(newStruct);
