Index: /trunk/psLib/test/dataManip/Makefile
===================================================================
--- /trunk/psLib/test/dataManip/Makefile	(revision 729)
+++ /trunk/psLib/test/dataManip/Makefile	(revision 730)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/sysUtils
 ##
-##  $Revision: 1.3 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-05-14 01:12:32 $
+##  $Revision: 1.4 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-05-19 01:52:07 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +18,7 @@
 TARGET = tst_psStats00 \
          tst_psStats01 \
-         tst_psStats02
+         tst_psStats02 \
+         tst_psStats03 \
+         tst_psStats04
 
 all: $(TARGET)
@@ -25,4 +27,6 @@
 tst_psStats01:		tst_psStats01.o
 tst_psStats02:		tst_psStats02.o
+tst_psStats03:		tst_psStats03.o
+tst_psStats04:		tst_psStats04.o
 
 clean:
Index: /trunk/psLib/test/dataManip/tst_psStats03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats03.c	(revision 730)
+++ /trunk/psLib/test/dataManip/tst_psStats03.c	(revision 730)
@@ -0,0 +1,77 @@
+/*****************************************************************************
+    This routine must ensure that PS_STAT_SAMPLE_MEDIAN is correctly computed
+    by the procedure psArrayStats().
+ *****************************************************************************/
+#include <stdio.h>
+#include "psLib.h"
+#include "psTest.h"
+#define N1 1029
+#define N ((4 * N1) + 1)
+
+int main()
+{
+    psStats *myStats    = NULL;
+    psStats *myStats2   = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    psVector *myVector  = NULL;
+    psVector *maskVector= NULL;
+    float median        = 1e99;
+    float realMedian1   = 1e99;
+    float realMedian2   = 1e99;
+
+    printPositiveTestHeader(stdout,
+                            "psStats functions",
+                            "PS_STAT_SAMPLE_MEDIAN");
+
+    myStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
+    myVector = psVectorAlloc(PS_TYPE_FLOAT, N);
+    myVector->n = N;
+    maskVector = psVectorAlloc(PS_TYPE_UINT8, N);
+    maskVector->n = N;
+
+    for (i=0;i<N;i++) {
+        myVector->vec.f[i] = (float) i;
+        if (i < (N/2)) {
+            maskVector->vec.ui8[i] = 0;
+            if (myVector->vec.f[i] < realMedian2) {
+                realMedian2 = myVector->vec.f[i];
+            }
+        } else {
+            maskVector->vec.ui8[i] = 1;
+            if (myVector->vec.f[i] < realMedian1) {
+                realMedian1 = myVector->vec.f[i];
+            }
+        }
+    }
+
+    myStats2 = psArrayStats(myVector, NULL, 0, myStats);
+    median = myStats2->sampleMedian;
+
+    printf("Called psArrayStats() on a vector with no elements masked.\n");
+    printf("The expected median was %f.  The calculated median was %f.\n",
+           (float) (N-1)/2, median);
+    if (median == (float) (N-1)/2) {
+        testStatus = true;
+    } else {
+        testStatus = false;
+    }
+
+    myStats2 = psArrayStats(myVector, maskVector, 1, myStats);
+    median = myStats2->sampleMedian;
+    printf("Called psArrayStats() on a vector with last N/2 elements masked.\n");
+    printf("The expected median was %f.  The calculated median was %f.\n",
+           (float) (N-3)/4, median);
+    if (median == (float) (N-3)/4) {
+        testStatus = true;
+    } else {
+        testStatus = false;
+    }
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/dataManip/tst_psStats04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psStats04.c	(revision 730)
+++ /trunk/psLib/test/dataManip/tst_psStats04.c	(revision 730)
@@ -0,0 +1,66 @@
+/*****************************************************************************
+    This routine must ensure that PS_STAT_NVALUES is correctly computed
+    by the procedure psArrayStats().
+ *****************************************************************************/
+#include <stdio.h>
+#include "psLib.h"
+#include "psTest.h"
+#define N1 1029
+#define N ((4 * N1) + 1)
+
+int main()
+{
+    psStats *myStats    = NULL;
+    psStats *myStats2   = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    psVector *myVector  = NULL;
+    psVector *maskVector= NULL;
+
+    printPositiveTestHeader(stdout,
+                            "psStats functions",
+                            "PS_STAT_NVALUES");
+
+    myStats = psStatsAlloc(PS_STAT_NVALUES);
+    myVector = psVectorAlloc(PS_TYPE_FLOAT, N);
+    myVector->n = N;
+    maskVector = psVectorAlloc(PS_TYPE_UINT8, N);
+    maskVector->n = N;
+
+    for (i=0;i<N;i++) {
+        myVector->vec.f[i] = (float) i;
+        if (i < (N/2)) {
+            maskVector->vec.ui8[i] = 0;
+        } else {
+            maskVector->vec.ui8[i] = 1;
+        }
+    }
+
+    myStats2 = psArrayStats(myVector, NULL, 0, myStats);
+
+    printf("Called psArrayStats() on a vector with no elements masked.\n");
+    printf("The expected nvalues was %d.  The calculated nvalues was %d.\n",
+           N, myStats2->nValues);
+    if (myStats2->nValues == N) {
+        testStatus = true;
+    } else {
+        testStatus = false;
+    }
+
+    myStats2 = psArrayStats(myVector, maskVector, 1, myStats);
+    printf("Called psArrayStats() on a vector with last N/2 elements masked.\n");
+    printf("The expected nvalues was %d.  The calculated nvalues was %d.\n",
+           N/2, myStats2->nValues);
+    if (myStats2->nValues == N/2) {
+        testStatus = true;
+    } else {
+        testStatus = false;
+    }
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
