Index: trunk/psLib/test/math/tst_psSpline1D.c
===================================================================
--- trunk/psLib/test/math/tst_psSpline1D.c	(revision 5155)
+++ trunk/psLib/test/math/tst_psSpline1D.c	(revision 5181)
@@ -13,6 +13,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-27 23:19:47 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-29 20:20:32 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -54,10 +54,8 @@
     psLogSetFormat("HLNM");
     psLogSetLevel( PS_LOG_INFO );
-
-    return ( ! runTestSuite( stderr, "psSpline1D", tests, argc, argv ) );
-}
-
-psS32 psSplineAllocTest()
-{
+    //
+    // Set the following trace leevls to track what is happening in the
+    // various functions in psSpline.c
+    //
     psTraceSetLevel(".", 0);
     psTraceSetLevel("spline1DFree", 0);
@@ -66,8 +64,4 @@
     psTraceSetLevel("vectorBinDisectF64", 0);
     psTraceSetLevel("p_psVectorBinDisect", 0);
-    psTraceSetLevel("fullInterpolate1DF32", 0);
-    psTraceSetLevel("fullInterpolate1DF64", 0);
-    psTraceSetLevel("interpolate1DF32", 0);
-    psTraceSetLevel("p_psVectorInterpolate", 0);
     psTraceSetLevel("psSpline1DAlloc", 0);
     psTraceSetLevel("psVectorFitSpline1D", 0);
@@ -75,8 +69,22 @@
     psTraceSetLevel("psSpline1DEvalVector", 0);
 
+    return ( ! runTestSuite( stderr, "psSpline1D", tests, argc, argv ) );
+}
+
+psS32 psSplineAllocTest()
+{
+    psTraceSetLevel(".", 0);
+    psTraceSetLevel("spline1DFree", 0);
+    psTraceSetLevel("calculateSecondDerivs", 0);
+    psTraceSetLevel("vectorBinDisectF32", 0);
+    psTraceSetLevel("vectorBinDisectF64", 0);
+    psTraceSetLevel("p_psVectorBinDisect", 0);
+    psTraceSetLevel("psSpline1DAlloc", 0);
+    psTraceSetLevel("psVectorFitSpline1D", 0);
+    psTraceSetLevel("psSpline1DEval", 0);
+    psTraceSetLevel("psSpline1DEvalVector", 0);
+
     psS32 testStatus = true;
     psS32  currentId = psMemGetId();
-
-    printPositiveTestHeader(stdout, "psSpline functions", "psSpline1DAlloc()");
 
     psSpline1D *tmpSpline = psSpline1DAlloc();
@@ -113,5 +121,4 @@
     }
 
-    printFooter(stdout, "psSpline functions", "psSpline1DAlloc()", testStatus);
     return(testStatus);
 }
@@ -119,5 +126,5 @@
 
 /*********************************************************************************
-t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
+psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
 simple x->y mapping (defined by myFunc00() below).  We do this for both F32
 and F64 versions of the input x and y vectors.
@@ -128,7 +135,8 @@
 }
 
-psS32 t00(psS32 NumSplines)
-{
-    printf("t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n");
+psS32 psSplineEvalTest_sub00(psS32 NumSplines)
+{
+    printf("\n");
+    printf("psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n");
     printf("simple x->y mapping (defined by myFunc00()).  We do this for both F32\n");
     printf("and F64 versions of the input x and y vectors.\n");
@@ -159,6 +167,4 @@
     }
 
-    printPositiveTestHeader(stdout, "psSpline functions",
-                            "psVectorFitSpline1D, psSpline1DEval(), F32, F32");
 
     tmpSpline = psVectorFitSpline1D(xF32, yF32);
@@ -221,7 +227,4 @@
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     }
-    printFooter(stdout, "psSpline functions",
-                "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);
-
     /****************************************************************************/
     /*    PS_TYPE_F64, PS_TYPE_F64 test          */
@@ -238,7 +241,4 @@
         yF64->data.F64[i] = (psF64) myFunc00(xF32->data.F32[i]);
     }
-
-    printPositiveTestHeader(stdout, "psSpline functions",
-                            "psVectorFitSpline1D, psSpline1DEval(), F64, F64");
 
     tmpSpline = psVectorFitSpline1D(xF64, yF64);
@@ -301,12 +301,9 @@
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     }
-    printFooter(stdout, "psSpline functions",
-                "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus);
-
     return (testStatus);
 }
 
 /*********************************************************************************
-t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a
+psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a
 more complicated x->y mapping (defined by myFunc00b() below).  We do this for
 both F32 and F64 versions of the input x and y vectors.
@@ -321,7 +318,8 @@
 }
 
-psS32 t00b(psS32 NumSplines)
-{
-    printf("t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n");
+psS32 psSplineEvalTest_sub00b(psS32 NumSplines)
+{
+    printf("\n");
+    printf("psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n");
     printf("more complicated x->y mapping (defined by myFunc00b()).  We do this for\n");
     printf("both F32 and F64 versions of the input x and y vectors.\n");
@@ -352,7 +350,4 @@
     }
 
-    printPositiveTestHeader(stdout, "psSpline functions",
-                            "psVectorFitSpline1D, psSpline1DEval(), F32, F32");
-
     tmpSpline = psVectorFitSpline1D(xF32, yF32);
     if (tmpSpline == NULL) {
@@ -414,7 +409,4 @@
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     }
-    printFooter(stdout, "psSpline functions",
-                "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);
-
     /****************************************************************************/
     /*    PS_TYPE_F64, PS_TYPE_F64 test          */
@@ -431,7 +423,4 @@
         yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]);
     }
-
-    printPositiveTestHeader(stdout, "psSpline functions",
-                            "psVectorFitSpline1D, psSpline1DEval(), F64, F64");
 
     tmpSpline = psVectorFitSpline1D(xF64, yF64);
@@ -494,7 +483,172 @@
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     }
-    printFooter(stdout, "psSpline functions",
-                "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus);
-
+    return (testStatus);
+}
+
+
+psS32 psSplineEvalTest_sub00c(psS32 NumSplines)
+{
+    printf("\n");
+    printf("psSplineEvalTest_sub00c(): This is similar to psSplineEvalTest_sub00b()\n");
+    printf("except that the x vector is NULL.\n");
+    psS32 testStatus = true;
+    psS32 memLeaks=0;
+    psF32 x;
+    psF32 y;
+    psS32  currentId = psMemGetId();
+    psVector *xF32 = NULL;
+    psVector *xF64 = NULL;
+    psVector *yF32 = NULL;
+    psVector *yF64 = NULL;
+    psSpline1D *tmpSpline = NULL;
+
+    /****************************************************************************/
+    /*    PS_TYPE_F32, PS_TYPE_F32 test          */
+    /****************************************************************************/
+    xF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32);
+    xF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64);
+    yF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32);
+    yF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64);
+
+    for (psS32 i=0;i<NumSplines+1;i++) {
+        xF32->data.F32[i] = (psF32) i;
+        xF64->data.F64[i] = (psF64) i;
+        yF32->data.F32[i] = (psF32) myFunc00b(xF32->data.F32[i]);
+        yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]);
+    }
+
+    tmpSpline = psVectorFitSpline1D(NULL, yF32);
+    if (tmpSpline == NULL) {
+        printf("TEST ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != NumSplines) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->n member.\n");
+        printf("            psSpline1D->NumSplines was %d, should be %d.\n", tmpSpline->n, NumSplines);
+        testStatus = false;
+    }
+
+    if (tmpSpline->spline == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline member.\n");
+        testStatus = false;
+    } else {
+        for (psS32 i = 0 ; i < NumSplines ; i++) {
+            if (tmpSpline->spline[i] == NULL) {
+                printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline[%d] member.\n", i);
+                testStatus = false;
+            } else {
+                if (psTraceGetLevel(__func__) >= 6) {
+                    PS_POLY_PRINT_1D(tmpSpline->spline[i]);
+                }
+            }
+        }
+    }
+
+    if (tmpSpline->knots == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->knots member.\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->p_psDeriv2 == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->p_psDeriv2 member.\n");
+        testStatus = false;
+    }
+
+    if (testStatus == true) {
+        for (psS32 i=0;i<NumSplines;i++) {
+            x = 0.5 + (float) i;
+            y = psSpline1DEval(tmpSpline, x);
+            if (CheckErrorF32(y, myFunc00b(x))) {
+                printf("TEST ERROR: f(%f) is %f, should be %f\n", x, y, myFunc00b(x));
+                testStatus = false;
+            }
+        }
+    }
+
+    psFree(tmpSpline);
+    psFree(xF32);
+    psFree(xF64);
+    psFree(yF32);
+    psFree(yF64);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    /****************************************************************************/
+    /*    PS_TYPE_F64, PS_TYPE_F64 test          */
+    /****************************************************************************/
+    xF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32);
+    xF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64);
+    yF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32);
+    yF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64);
+
+    for (psS32 i=0;i<NumSplines+1;i++) {
+        xF32->data.F32[i] = (psF32) i;
+        xF64->data.F64[i] = (psF64) i;
+        yF32->data.F32[i] = (psF32) myFunc00b(xF32->data.F32[i]);
+        yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]);
+    }
+
+    tmpSpline = psVectorFitSpline1D(NULL, yF64);
+    if (tmpSpline == NULL) {
+        printf("TEST ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != NumSplines) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->n member.\n");
+        printf("            psSpline1D->NumSplines was %d, should be %d.\n", tmpSpline->n, NumSplines);
+        testStatus = false;
+    }
+
+    if (tmpSpline->spline == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline member.\n");
+        testStatus = false;
+    } else {
+        for (psS32 i = 0 ; i < NumSplines ; i++) {
+            if (tmpSpline->spline[i] == NULL) {
+                printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline[%d] member.\n", i);
+                testStatus = false;
+            } else {
+                if (psTraceGetLevel(__func__) >= 6) {
+                    PS_POLY_PRINT_1D(tmpSpline->spline[i]);
+                }
+            }
+        }
+    }
+
+    if (tmpSpline->knots == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->knots member.\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->p_psDeriv2 == NULL) {
+        printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->p_psDeriv2 member.\n");
+        testStatus = false;
+    }
+
+    if (testStatus == true) {
+        for (psS32 i=0;i<NumSplines;i++) {
+            x = 0.5 + (float) i;
+            y = psSpline1DEval(tmpSpline, x);
+            if (CheckErrorF32(y, myFunc00b(x))) {
+                printf("TEST ERROR: f(%f) is %f, should be %f\n", x, y, myFunc00b(x));
+                testStatus = false;
+            }
+        }
+    }
+
+    psFree(tmpSpline);
+    psFree(xF32);
+    psFree(xF64);
+    psFree(yF32);
+    psFree(yF64);
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
     return (testStatus);
 }
@@ -510,8 +664,4 @@
     psTraceSetLevel("vectorBinDisectF64", 0);
     psTraceSetLevel("p_psVectorBinDisect", 0);
-    psTraceSetLevel("fullInterpolate1DF32", 0);
-    psTraceSetLevel("fullInterpolate1DF64", 0);
-    psTraceSetLevel("interpolate1DF32", 0);
-    psTraceSetLevel("p_psVectorInterpolate", 0);
     psTraceSetLevel("psSpline1DAlloc", 0);
     psTraceSetLevel("psVectorFitSpline1D", 0);
@@ -519,10 +669,10 @@
     psTraceSetLevel("psSpline1DEvalVector", 0);
 
-    return(t00(100) & t00b(100));
-}
-
-
-
-psS32 t01(psS32 NumSplines)
+    return(psSplineEvalTest_sub00(95) & psSplineEvalTest_sub00b(95) & psSplineEvalTest_sub00c(95));
+}
+
+
+
+psS32 psSplineEvalVectorTest_sub00(psS32 NumSplines)
 {
     psS32 testStatus = true;
@@ -546,7 +696,4 @@
         yF32->data.F32[i] = (psF32) i;
     }
-
-    printPositiveTestHeader(stdout, "psSpline functions",
-                            "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32");
 
     tmpSpline = psVectorFitSpline1D(xF32, yF32);
@@ -630,7 +777,4 @@
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     }
-    printFooter(stdout, "psSpline functions",
-                "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32", testStatus);
-
     return (testStatus);
 }
@@ -644,8 +788,4 @@
     psTraceSetLevel("vectorBinDisectF64", 0);
     psTraceSetLevel("p_psVectorBinDisect", 0);
-    psTraceSetLevel("fullInterpolate1DF32", 0);
-    psTraceSetLevel("fullInterpolate1DF64", 0);
-    psTraceSetLevel("interpolate1DF32", 0);
-    psTraceSetLevel("p_psVectorInterpolate", 0);
     psTraceSetLevel("psSpline1DAlloc", 0);
     psTraceSetLevel("psVectorFitSpline1D", 0);
@@ -653,8 +793,6 @@
     psTraceSetLevel("psSpline1DEvalVector", 0);
 
-    return(t01(10));
-}
-
-
-
-//is the way
+    return(psSplineEvalVectorTest_sub00(10));
+}
+
+
