Index: trunk/psLib/test/TABLE-SDRS-CH06-DataManip
===================================================================
--- trunk/psLib/test/TABLE-SDRS-CH06-DataManip	(revision 13175)
+++ trunk/psLib/test/TABLE-SDRS-CH06-DataManip	(revision 13305)
@@ -5,14 +5,18 @@
 -------------------------------------------------------------------------------
 psVectorSort()
-			10		10	2	10
-    We only test with NULL, size 1, and size 7 vectors.
-    Add a test with NULL input, non-NULL output.
+			10		10	10	10
+    in mathtypes/tap_psVectorSort.c
+    Many more types are tested successfully than required in the SDRS.
 psVectorSortIndex()
-			10		10	2	10
-    We only test with NULL, size 1, and size 7 vectors.
-    Add a test with NULL input, non-NULL output.
+			10		10	10	10
+    in mathtypes/tap_psVectorSortIndex.c
+    Many more typres are tested successfully than required in the SDRS.
 psVectorStats()		5		10	5	5
+    files: math/tap_psStats00.c - math/tap_psStats09.c
     Must review these files more.
     More extensie robust stats?
+    Preset answers
+    Unclear what types should be supported from SDRS:
+	psS8, psU16, psF32, psF64
 psStatsAlloc()
 			na		na	na	10
@@ -38,32 +42,35 @@
 			8		na	10	8
 psPolynomial1DAlloc()
-			8		na	na	5
-    Can we test with negative polynomial order?
-    How about verifying the data is allocated, and initialized?
+			10		10	10	10	na
+    math/tap_psPolynomial.c
 psPolynomial2DAlloc()
-			8		na	na	5
-    Can we test with negative polynomial order?
+			10		10	10	10	na
+    math/tap_psPolynomial.c
 psPolynomial3DAlloc()
-			8		na	na	5
-    Can we test with negative polynomial order?
+			10		10	10	10	na
+    math/tap_psPolynomial.c
 psPolynomial4DAlloc()
-			8		na	na	5
-    Can we test with negative polynomial order?
+			10		10	10	10	na
+    math/tap_psPolynomial.c
 psPolynomial1DEval()
 			10		10	1	8
     We only allocate polynomials with 4 terms
-    We should ensure that asking for negatiev number of terms fails nicely.
+    We should ensure that asking for negative number of terms fails nicely.
+    The test uses precomputed results.
 psPolynomial2DEval()
 			10		10	1	5
     We only allocate polynomials with 4 terms
 	Must vary x,y number of terms.
+    The test uses precomputed results.
 psPolynomial3DEval()
 			10		10	1	5
     We only allocate polynomials with 4 terms
 	Must vary x,y,z number of terms.
+    The test uses precomputed results.
 psPolynomial4DEval()
 			10		10	1	5
     We only allocate polynomials with 4 terms
 	Must vary w,x,y,z number of terms.
+    The test uses precomputed results.
 psPolynomial1DEvalVector()
 			10		10	5	9
Index: trunk/psLib/test/math/tap_psPolynomial.c
===================================================================
--- trunk/psLib/test/math/tap_psPolynomial.c	(revision 13175)
+++ trunk/psLib/test/math/tap_psPolynomial.c	(revision 13305)
@@ -16,6 +16,6 @@
 *    XXX: Compare to FLT_EPSILON
 * 
-*    @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*    @date $Date: 2007-05-01 00:08:52 $
+*    @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*    @date $Date: 2007-05-08 06:21:16 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -35,6 +35,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-
-    plan_tests(26);
+    plan_tests(51);
 
     // This test will allocate a 1D polynomial and verify the structure allocated
@@ -75,11 +74,27 @@
 
 
-    if (0) {
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) != NULL) {
-            diag("psPolynomial1DAlloc() Returned structure but expected NULL");
-        }
-    }
+    // This test will allocate a Chebyshev 1D polynomial and verify the structure allocated
+    {
+        psMemId id = psMemGetId();
+        psPolynomial1D* my1DPoly  = NULL;
+        my1DPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, ORDER);
+        ok(my1DPoly != NULL, "Chebyshev 1D polynomial allocated successfully");
+        skip_start(my1DPoly == NULL, 1, "Skipping tests because psPolynomial1DAlloc() failed");
+        ok(my1DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial1DAlloc(): Chebyshev  type set correctly");
+        skip_end();
+        psFree(my1DPoly);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Attempt to allocate with negative order
+    // Following should generate error msg for negative terms
+    if (1) {
+        psMemId id = psMemGetId();
+        ok(psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) == NULL,
+          "psPolynomial1DAlloc() returned NULL with negative polynomial order");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // This test will allocate a 2D polynomial and verify the structure allocated
@@ -122,16 +137,29 @@
     }
 
-    if (0) {
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) != NULL) {
-            diag("psPolynomial2DAlloc() returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) != NULL) {
-            diag("psPolynomial2DAlloc() returned structure but expected NULL");
-        }
-    }
+
+    // This test will allocate a Chebyshev 2D polynomial and verify the structure allocated
+    {
+        psMemId id = psMemGetId();
+        psPolynomial2D* my2DPoly = NULL;
+        my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1);
+        ok(my2DPoly != NULL, "Chebyshev 2D polynomial allocated successfully");
+        skip_start(my2DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed");
+        skip_end();
+        psFree(my2DPoly);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Attempt to allocate with negative order
+    // Following should generate error msg for negative terms
+    if (1) {
+        psMemId id = psMemGetId();
+        ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) == NULL, 
+          "psPolynomial2DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) == NULL,
+          "psPolynomial2DAlloc() returned NULL with negative polynomial order");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // This test will allocate a 3D polynomial and verify the structure allocated
@@ -179,21 +207,33 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
-    if (0) {
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) != NULL) {
-            diag("psPolynomial3DAlloc(): returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) != NULL) {
-            diag("psPolynomial3DAlloc() returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) != NULL) {
-            diag("psPolynomial3DAlloc(): returned structure but expected NULL");
-        }
-    }
+
+
+    // This test will allocate a Chebyshev 3D polynomial and verify the structure allocated
+    {
+        psMemId id = psMemGetId();
+        psPolynomial3D* my3DPoly = NULL;
+        my3DPoly = psPolynomial3DAlloc(PS_POLYNOMIAL_CHEB, ORDER, ORDER+1, ORDER+2);
+        ok(my3DPoly != NULL, "Chebyshev 3D polynomial allocated successfully");
+        skip_start(my3DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed");
+        ok(my3DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial3DAlloc(): Chebyshev type set correctly");
+        skip_end();
+        psFree(my3DPoly);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Attempt to allocate with negative order
+    // Following should generate error msg for negative terms
+    if (1) {
+        psMemId id = psMemGetId();
+        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) == NULL, 
+          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) == NULL, 
+          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) == NULL,
+          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // This test will allocate a 4D polynomial and verify the structure allocated
@@ -245,28 +285,35 @@
     }
 
-    if (0) {
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) != NULL) {
-            diag("psPolynomial4DAlloc(): returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) != NULL) {
-            diag("psPolynomial4DAlloc(): returned structure but expected NULL");
-            psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) != NULL) {
-            diag("psPolynomial4DAlloc(): returned structure but expected NULL");
-            psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
-        }
-        // Attempt to allocate with negative order
-        // Following should generate error msg for negative terms
-        if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) != NULL) {
-            diag("psPolynomial4DAlloc(): returned structure but expected NULL");
-        }
-    }
+
+    // This test will allocate a Chebyshev 4D polynomial and verify the structure allocated
+    {
+        psMemId id = psMemGetId();
+        psPolynomial4D* my4DPoly = NULL;
+        my4DPoly = psPolynomial4DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1,ORDER+2,ORDER+3);
+        ok(my4DPoly != NULL, "Chebyshev 4D polynomial allocated successfully");
+        skip_start(my4DPoly == NULL, 1, "Skipping tests because psPolynomial4DAlloc() failed");
+        ok(my4DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial4DAlloc(): Chebyshev type set correctly");
+        skip_end();
+        psFree(my4DPoly);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Attempt to allocate with negative order
+    // Following should generate error msg for negative terms
+    if (1) {
+        psMemId id = psMemGetId();
+        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) == NULL, 
+          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) == NULL, 
+          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) == NULL,
+          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
+        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) == NULL,
+          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
 }
 
Index: trunk/psLib/test/math/tap_psPolynomialEval1D.c
===================================================================
--- trunk/psLib/test/math/tap_psPolynomialEval1D.c	(revision 13175)
+++ trunk/psLib/test/math/tap_psPolynomialEval1D.c	(revision 13305)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.7 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2007-05-02 04:20:06 $
+*  @version  $Revision: 1.8 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2007-05-08 06:21:16 $
 *
 *  XXX: Probably should test single- and multi-dimensional polynomials in
@@ -76,6 +76,5 @@
 
         // Set polynomial members
-        for(psS32 i = 0; i < TERMS; i++)
-        {
+        for(psS32 i = 0; i < TERMS; i++) {
             polyOrd->coeff[i] = poly1DCoeff[i];
             polyOrd->mask[i]  = poly1DMask[i];
@@ -84,6 +83,5 @@
         // Evaluate test points and verify results
         bool errorFlag = false;
-        for(psS32 i = 0; i < TESTPOINTS; i++)
-        {
+        for(psS32 i = 0; i < TESTPOINTS; i++) {
             psF64 result = psPolynomial1DEval(polyOrd,poly1DXValue[i]);
             if (fabs(poly1DXResult[i]-result) > ERROR_TOL ) {
Index: trunk/psLib/test/math/tap_psStats00.c
===================================================================
--- trunk/psLib/test/math/tap_psStats00.c	(revision 13175)
+++ trunk/psLib/test/math/tap_psStats00.c	(revision 13305)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-10 21:09:30 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-08 06:21:16 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -82,36 +82,4 @@
     }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     // Call psVectorStats() with no vector mask.
     {
Index: trunk/psLib/test/mathtypes/tap_psVectorSort.c
===================================================================
--- trunk/psLib/test/mathtypes/tap_psVectorSort.c	(revision 13175)
+++ trunk/psLib/test/mathtypes/tap_psVectorSort.c	(revision 13305)
@@ -11,22 +11,20 @@
  *  Sort vector with one element
  *  Verify the sort for all supported types.
+ *  Sort input vector into itself
  *  Output vector is smaller than input vector
  *  Output vector is different type from input vector
- *  Sort input float vector into itself
- *  Free float vectors
  *
  *  @author  Ross Harman, GLG, MHPCC
  *
- *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-04-19 03:50:44 $
+ *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-08 06:21:16 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  *
  */
-
 #include <pslib.h>
 #include "tap.h"
 #include "pstap.h"
-
+#define VERBOSE 0
 
 #define tstVectorSortByType(datatype, boolOutNull, value) \
@@ -34,5 +32,5 @@
     psMemId id = psMemGetId(); \
     psVector *out = NULL; \
-    psVector *in = psVectorAlloc(7,PS_TYPE_##datatype); \
+    psVector *in = psVectorAlloc(7, PS_TYPE_##datatype); \
     if (boolOutNull) { \
         out = NULL; \
@@ -74,5 +72,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(244);
+    plan_tests(246);
 
 
@@ -90,9 +88,9 @@
     {
         psMemId id = psMemGetId();
-        psVector *in = psVectorAlloc(7, PS_TYPE_F32);
-        in->type.type = PS_TYPE_BOOL;
+        psVector *in = psVectorAlloc(7, PS_TYPE_BOOL);
         psVector *out = psVectorSort(NULL, in);
         ok(out == NULL, "Did return NULL on error");
         psFree(in);
+        psFree(out);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -236,3 +234,30 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+
+
+    // Sort large input vector
+    {
+        #define N 1000000
+        psMemId id = psMemGetId();
+        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
+        for (int i = 0 ; i < N ; i++) {
+            in->data.S32[N-i-1] = i;
+        }
+        psVector *out = psVectorSort(NULL, in);
+        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
+        bool errorFlag = false;
+        for (int i = 0 ; i < N ; i++) {
+            if (out->data.S32[i] != i) {
+                if (VERBOSE) {
+                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.S32[i], i);
+                }
+                errorFlag = true;
+            }
+        }
+        ok(!errorFlag, "psVectorSort() correctly sorted a large input vector");
+        skip_end();
+        psFree(in);
+        psFree(out);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
Index: trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c
===================================================================
--- trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c	(revision 13175)
+++ trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c	(revision 13305)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, GLG, MHPCC
  *
- *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-04-19 03:50:44 $
+ *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-08 06:21:16 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -23,4 +23,5 @@
 #include "tap.h"
 #include "pstap.h"
+#define VERBOSE 0
 
 #define tstVectorSortIndexByType(datatype, boolOutNull, value) \
@@ -28,5 +29,5 @@
     psMemId id = psMemGetId(); \
     psVector *out = NULL; \
-    psVector *in = psVectorAlloc( 5, PS_TYPE_##datatype ); \
+    psVector *in = psVectorAlloc(5, PS_TYPE_##datatype); \
     in->data.datatype[0] = 7+value; \
     in->data.datatype[1] = 9+value; \
@@ -37,8 +38,8 @@
         out = NULL; \
     } else { \
-        out = psVectorAlloc(5,PS_TYPE_##datatype); \
+        out = psVectorAlloc(5, PS_TYPE_##datatype); \
     } \
     psVector *tempVec = out; \
-    out = psVectorSortIndex(out,in); \
+    out = psVectorSortIndex(out, in); \
     if (!boolOutNull) { \
         ok(tempVec == out, "Return value equal to orignal output argument passed to function"); \
@@ -71,4 +72,5 @@
         psVector *out = psVectorSortIndex(NULL, NULL);
         ok(out == NULL, "psVectorSortIndex() return NULL with NULL input specified");
+        psFree(out);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -78,9 +80,9 @@
     {
         psMemId id = psMemGetId();
-        psVector *in = psVectorAlloc(5, PS_TYPE_U8);
-        in->type.type = PS_TYPE_BOOL;
+        psVector *in = psVectorAlloc(5, PS_TYPE_BOOL);
         psVector *out = psVectorSortIndex(NULL, in);
         ok(out == NULL, "psVectorSortIndex() returned NULL with unallowed input vector type");
         psFree(in);
+        psFree(out);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -178,3 +180,30 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+
+
+    // Sort large input vector
+    {
+        #define N 1000000
+        psMemId id = psMemGetId();
+        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
+        for (int i = 0 ; i < N ; i++) {
+            in->data.S32[N-i-1] = i;
+        }
+        psVector *out = psVectorSortIndex(NULL, in);
+        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
+        bool errorFlag = false;
+        for (int i = 0 ; i < N ; i++) {
+            if (out->data.U32[i] != N-i-1) {
+                if (VERBOSE) {
+                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.U32[i], i);
+                }
+                errorFlag = true;
+            }
+        }
+        ok(!errorFlag, "psVectorSortIndex() correctly sorted a large input vector");
+        skip_end();
+        psFree(in);
+        psFree(out);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
