Index: trunk/psLib/src/dataManip/psStats.c
===================================================================
--- trunk/psLib/src/dataManip/psStats.c	(revision 1327)
+++ trunk/psLib/src/dataManip/psStats.c	(revision 1328)
@@ -88,4 +88,58 @@
 /*****************************************************************************/
 
+bool p_psGetStatValue(const psStats* stats, double* value)
+{
+
+    switch (stats->options &
+            ~ (PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
+    case PS_STAT_SAMPLE_MEAN:
+        *value = stats->sampleMean;
+        return true;
+
+    case PS_STAT_SAMPLE_MEDIAN:
+        *value = stats->sampleMedian;
+        return true;
+
+    case PS_STAT_SAMPLE_STDEV:
+        *value = stats->sampleStdev;
+        return true;
+
+    case PS_STAT_ROBUST_MEAN:
+        *value = stats->robustMean;
+        return true;
+
+    case PS_STAT_ROBUST_MEDIAN:
+        *value = stats->robustMedian;
+        return true;
+
+    case PS_STAT_ROBUST_MODE:
+        *value = stats->robustMode;
+        return true;
+
+    case PS_STAT_ROBUST_STDEV:
+        *value = stats->robustStdev;
+        return true;
+
+    case PS_STAT_CLIPPED_MEAN:
+        *value = stats->clippedMean;
+        return true;
+
+    case PS_STAT_CLIPPED_STDEV:
+        *value = stats->clippedStdev;
+        return true;
+
+    case PS_STAT_MAX:
+        *value = stats->max;
+        return true;
+
+    case PS_STAT_MIN:
+        *value = stats->min;
+        return true;
+
+    default:
+        return false;
+    }
+}
+
 /*****************************************************************************
 p_psVectorPrint(myVector, maskVector, maskVal, stats): a private internal
@@ -140,4 +194,5 @@
 calculated in this routine.
  *****************************************************************************/
+
 void p_psVectorSampleMean(const psVector *restrict myVector,
                           const psVector *restrict maskVector,
@@ -1790,4 +1845,43 @@
 
 /******************************************************************************
+p_psConvertToF32(myVector, maskVector, maskVal, stats): this is the cheap
+way to support a variety of vector data types: we simply convert the input
+vector to F32 at the beginning, and write all of our functions in F32.  If
+the vast majority of all vector stat operations are F32 (or any other single
+type), then this is probably the best way to go.  Otherwise, when the
+algorithms stablize, we will then macro everything and put type support in
+the various stat functions.
+ *****************************************************************************/
+psVector *p_psConvertToF32(psStats *stats,
+                           psVector *in,
+                           psVector *mask,
+                           unsigned int maskVal)
+{
+    int i = 0;
+    psVector *tmp = NULL;
+
+    if (in->type.type == PS_TYPE_S32) {
+        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
+        for (i=0;i<in->n;i++) {
+            tmp->data.F32[i] = (float) in->data.S32[i];
+        }
+    } else if (in->type.type == PS_TYPE_U32) {
+        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
+        for (i=0;i<in->n;i++) {
+            tmp->data.F32[i] = (float) in->data.U32[i];
+        }
+    } else if (in->type.type == PS_TYPE_F64) {
+        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
+        for (i=0;i<in->n;i++) {
+            tmp->data.F32[i] = (float) in->data.F64[i];
+        }
+    } else {
+        psAbort(__func__, "unsupported vector type 0x%x\n", in->type.type);
+    }
+    return(tmp);
+}
+
+
+/******************************************************************************
 psVectorStats(myVector, maskVector, maskVal, stats): this is the public API
 function which calls the above private stats functions based on what bits
@@ -1811,4 +1905,7 @@
                        unsigned int maskVal)
 {
+    psVector *inF32;
+    int mustFreeTmp = 1;
+
     // NOTE: Verify that this is the correct action.
     if (in == NULL) {
@@ -1817,4 +1914,10 @@
     if (stats == NULL) {
         return(NULL);
+    }
+
+    inF32 = p_psConvertToF32(stats, in, mask, maskVal);
+    if (inF32 == NULL) {
+        inF32 = in;
+        mustFreeTmp = 0;
     }
 
@@ -1826,5 +1929,5 @@
     }
 
-    PS_CHECK_VECTOR_TYPE(in, PS_TYPE_F32);
+    //    PS_CHECK_VECTOR_TYPE(in, PS_TYPE_F32);
     if (mask != NULL) {
         PS_CHECK_NULL_VECTOR(mask);
@@ -1883,58 +1986,8 @@
     }
 
+    if (mustFreeTmp == 1) {
+        psFree(inF32);
+    }
+
     return(stats);
 }
-
-bool p_psGetStatValue(const psStats* stats, double* value)
-{
-
-    switch (stats->options &
-            ~ (PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
-    case PS_STAT_SAMPLE_MEAN:
-        *value = stats->sampleMean;
-        return true;
-
-    case PS_STAT_SAMPLE_MEDIAN:
-        *value = stats->sampleMedian;
-        return true;
-
-    case PS_STAT_SAMPLE_STDEV:
-        *value = stats->sampleStdev;
-        return true;
-
-    case PS_STAT_ROBUST_MEAN:
-        *value = stats->robustMean;
-        return true;
-
-    case PS_STAT_ROBUST_MEDIAN:
-        *value = stats->robustMedian;
-        return true;
-
-    case PS_STAT_ROBUST_MODE:
-        *value = stats->robustMode;
-        return true;
-
-    case PS_STAT_ROBUST_STDEV:
-        *value = stats->robustStdev;
-        return true;
-
-    case PS_STAT_CLIPPED_MEAN:
-        *value = stats->clippedMean;
-        return true;
-
-    case PS_STAT_CLIPPED_STDEV:
-        *value = stats->clippedStdev;
-        return true;
-
-    case PS_STAT_MAX:
-        *value = stats->max;
-        return true;
-
-    case PS_STAT_MIN:
-        *value = stats->min;
-        return true;
-
-    default:
-        return false;
-    }
-}
