Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 563)
+++ trunk/psLib/src/math/psStats.c	(revision 642)
@@ -4,9 +4,11 @@
 #include <stdarg.h>
 #include "pslib.h"
-//#include "psMemory.h"
-//#include "psTrace.h"
-//#include "psString.h"
-//#include "psError.h"
-#include "psArray.h"
+#include "psMemory.h"
+#include "psTrace.h"
+#include "psString.h"
+#include "psError.h"
+/******************************************************************************
+//#include "psArray.h"
+ *****************************************************************************/
 #include "psStats.h"
 
@@ -65,7 +67,7 @@
     numBins = 1 + ((upper - lower) / size);
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
-    newHist->lower = psFloatArrayAlloc(numBins);
-    newHist->upper = psFloatArrayAlloc(numBins);
-    newHist->nums = psIntArrayAlloc(numBins);
+    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
+    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
+    newHist->nums =  psVectorAlloc(numBins, PS_TYPE_INT);
     newHist->minVal = lower;
     newHist->maxVal = upper;
@@ -76,6 +78,6 @@
 }
 
-psHistogram *psHistogramAllocGeneric(const psFloatArray *restrict lower,
-                                     const psFloatArray *restrict upper,
+psHistogram *psHistogramAllocGeneric(const psVector *restrict lower,
+                                     const psVector *restrict upper,
                                      float minVal,
                                      float maxVal)
@@ -90,11 +92,11 @@
     numBins = lower->n;
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
-    newHist->lower = psFloatArrayAlloc(numBins);
-    newHist->upper = psFloatArrayAlloc(numBins);
+    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
+    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     for (i=0;i<numBins;i++) {
-        newHist->lower->arr[i] = lower->arr[i];
-        newHist->upper->arr[i] = upper->arr[i];
-    }
-    newHist->nums = psIntArrayAlloc(numBins);
+        newHist->lower->vec.vecF[i] = lower->vec.vecF[i];
+        newHist->upper->vec.vecF[i] = upper->vec.vecF[i];
+    }
+    newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT);
     newHist->minVal = minVal;
     newHist->maxVal = maxVal;
@@ -124,6 +126,6 @@
         myHist->maxNum
  *****************************************************************************/
-psHistogram *psGetArrayHistogram(       psHistogram *restrict myHist,
-                                        const psFloatArray *restrict myArray)
+psHistogram *psGetArrayHistogram(psHistogram *restrict myHist,
+                                 const psVector *restrict myVector)
 {
     int i = 0;
@@ -132,14 +134,14 @@
 
     binSize = (myHist->maxVal - myHist->minVal) / (float) myHist->nums->n;
-    for (i=0;i<myArray->n;i++) {
-        if (myArray->arr[i] < myHist->minVal) {
+    for (i=0;i<myVector->n;i++) {
+        if (myVector->vec.vecF[i] < myHist->minVal) {
             myHist->minNum++;
-        } else if (myArray->arr[i] > myHist->maxVal) {
+        } else if (myVector->vec.vecF[i] > myHist->maxVal) {
             myHist->maxNum++;
         } else {
-            binNum = (int) ((myArray->arr[i] - myHist->minVal) / binSize);
-            if ((myArray->arr[i] >= myHist->lower->arr[i]) &&
-                    (myArray->arr[i] <= myHist->upper->arr[i])) {
-                myHist->nums->arr[i]++;
+            binNum = (int) ((myVector->vec.vecF[i] - myHist->minVal) / binSize);
+            if ((myVector->vec.vecF[i] >= myHist->lower->vec.vecF[i]) &&
+                    (myVector->vec.vecF[i] <= myHist->upper->vec.vecF[i])) {
+                myHist->nums->vec.vecI[i]++;
             } else {
                 psError(__func__, "data value was not within the bounds of the bin it should habe been in.");
@@ -153,6 +155,6 @@
     MISC STATISTICAL FUNCTIONS
  *****************************************************************************/
-float p_psArraySampleMean(const psFloatArray *restrict myArray,
-                          const psIntArray *restrict maskArray,
+float p_psArraySampleMean(const psVector *restrict myVector,
+                          const psVector *restrict maskVector,
                           unsigned int maskVal)
 {
@@ -160,13 +162,13 @@
     float mean = 0.0;
 
-    if (maskArray != NULL) {
-        for (i=0;i<myArray->n;i++) {
-            if (!(maskVal & maskArray->arr[i])) {
-                mean+= maskArray->arr[i];
+    if (maskVector != NULL) {
+        for (i=0;i<myVector->n;i++) {
+            if (!(maskVal & maskVector->vec.vecI[i])) {
+                mean+= maskVector->vec.vecI[i];
             }
         }
     } else {
-        for (i=0;i<myArray->n;i++) {
-            mean+= maskArray->arr[i];
+        for (i=0;i<myVector->n;i++) {
+            mean+= maskVector->vec.vecI[i];
         }
     }
@@ -174,6 +176,6 @@
 }
 
-float p_psArrayMax(const psFloatArray *restrict myArray,
-                   const psIntArray *restrict maskArray,
+float p_psArrayMax(const psVector *restrict myVector,
+                   const psVector *restrict maskVector,
                    unsigned int maskVal)
 {
@@ -181,16 +183,16 @@
     float max = -1e99;
 
-    if (maskArray != NULL) {
-        for (i=0;i<myArray->n;i++) {
-            if (!(maskVal & maskArray->arr[i])) {
-                if (myArray->arr[i] > max) {
-                    max = maskArray->arr[i];
+    if (maskVector != NULL) {
+        for (i=0;i<myVector->n;i++) {
+            if (!(maskVal & maskVector->vec.vecI[i])) {
+                if (myVector->vec.vecF[i] > max) {
+                    max = maskVector->vec.vecI[i];
                 }
             }
         }
     } else {
-        for (i=0;i<myArray->n;i++) {
-            if (myArray->arr[i] > max) {
-                max = maskArray->arr[i];
+        for (i=0;i<myVector->n;i++) {
+            if (myVector->vec.vecF[i] > max) {
+                max = maskVector->vec.vecI[i];
             }
         }
@@ -199,6 +201,6 @@
 }
 
-float p_psArrayMin(const psFloatArray *restrict myArray,
-                   const psIntArray *restrict maskArray,
+float p_psArrayMin(const psVector *restrict myVector, /* FLOATS */
+                   const psVector *restrict maskVector, /* INTS */
                    unsigned int maskVal)
 {
@@ -206,16 +208,16 @@
     float min = 1e99;
 
-    if (maskArray != NULL) {
-        for (i=0;i<myArray->n;i++) {
-            if (!(maskVal & maskArray->arr[i])) {
-                if (myArray->arr[i] < min) {
-                    min = maskArray->arr[i];
+    if (maskVector != NULL) {
+        for (i=0;i<myVector->n;i++) {
+            if (!(maskVal & maskVector->vec.vecI[i])) {
+                if (myVector->vec.vecF[i] < min) {
+                    min = maskVector->vec.vecI[i];
                 }
             }
         }
     } else {
-        for (i=0;i<myArray->n;i++) {
-            if (myArray->arr[i] < min) {
-                min = maskArray->arr[i];
+        for (i=0;i<myVector->n;i++) {
+            if (myVector->vec.vecF[i] < min) {
+                min = maskVector->vec.vecI[i];
             }
         }
@@ -224,6 +226,6 @@
 }
 
-int p_psArrayNValues(const psFloatArray *restrict myArray,
-                     const psIntArray *restrict maskArray,
+int p_psArrayNValues(const psVector *restrict myVector, // float
+                     const psVector *restrict maskVector, // ints
                      unsigned int maskVal)
 {
@@ -231,18 +233,18 @@
     int numData = 0;
 
-    if (maskArray != NULL) {
-        for (i=0;i<myArray->n;i++) {
-            if (!(maskVal & maskArray->arr[i])) {
+    if (maskVector != NULL) {
+        for (i=0;i<myVector->n;i++) {
+            if (!(maskVal & maskVector->vec.vecI[i])) {
                 numData++;
             }
         }
     } else {
-        numData = myArray->n;
+        numData = myVector->n;
     }
     return(numData);
 }
 
-psStats *psArrayStats(const psFloatArray *restrict myArray,
-                      const psIntArray *restrict maskArray,
+psStats *psArrayStats(const psVector *restrict myVector, // FLOAT
+                      const psVector *restrict maskVector, // INT
                       unsigned int maskVal,
                       psStats *stats)
@@ -251,17 +253,17 @@
 
     newStruct = psStatsAlloc(stats->options);
-    if (myArray == NULL) {
+    if (myVector == NULL) {
         psError(__func__,
-                "Input data array (myArray) was NULL.");
-    }
-
-    if ((maskArray != NULL) &&
-            (myArray->n != maskArray->n)) {
-        psError(__func__, "Array data and array mask are of different sizes.");
+                "Input data array (myVector) was NULL.");
+    }
+
+    if ((maskVector != NULL) &&
+            (myVector->n != maskVector->n)) {
+        psError(__func__, "Vector data and vector mask are of different sizes.");
     }
 
     switch (stats->options) {
     case PS_STAT_SAMPLE_MEAN:
-        newStruct->max = p_psArraySampleMean(myArray, maskArray, maskVal);
+        newStruct->max = p_psArraySampleMean(myVector, maskVector, maskVal);
         break;
     case PS_STAT_SAMPLE_MEDIAN:
@@ -317,11 +319,11 @@
         break;
     case PS_STAT_MAX:
-        newStruct->max = p_psArrayMax(myArray, maskArray, maskVal);
+        newStruct->max = p_psArrayMax(myVector, maskVector, maskVal);
         break;
     case PS_STAT_MIN:
-        newStruct->min = p_psArrayMin(myArray, maskArray, maskVal);
+        newStruct->min = p_psArrayMin(myVector, maskVector, maskVal);
         break;
     case PS_STAT_NVALUES:
-        newStruct->nValues = p_psArrayNValues(myArray, maskArray, maskVal);
+        newStruct->nValues = p_psArrayNValues(myVector, maskVector, maskVal);
         break;
     default:
