Index: /trunk/psLib/test/math/tst_psFunc00.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc00.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc00.c	(revision 4731)
@@ -13,7 +13,7 @@
 *    XXX: Modify these tests so that polynomials with a variety of different
 *    orders are created.
-*
-*    @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*    @date $Date: 2005-07-20 01:21:13 $
+* 
+*    @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*    @date $Date: 2005-08-08 21:44:09 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -43,4 +43,5 @@
 psS32 main(psS32 argc, char* argv[])
 {
+    psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
 
Index: /trunk/psLib/test/math/tst_psFunc01.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc01.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc01.c	(revision 4731)
@@ -15,4 +15,5 @@
 psS32 main()
 {
+    psLogSetFormat("HLNM");
     psS32 testStatus = true;
     float x = 0.0;
Index: /trunk/psLib/test/math/tst_psFunc02.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc02.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc02.c	(revision 4731)
@@ -16,4 +16,5 @@
 psS32 main()
 {
+    psLogSetFormat("HLNM");
     psS32 testStatus = true;
     psS32 memLeaks=0;
@@ -388,7 +389,7 @@
                     "psSpline1DAllocGeneric(): negative order",
                     testStatus);
+        // XXX: Currently, if you free a psStructure twice, it seg faults.  Why?
+        psFree(bounds);
     */
-    psFree(bounds);
-
     /****************************************************************************/
     /****************************************************************************/
Index: /trunk/psLib/test/math/tst_psFunc03.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc03.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc03.c	(revision 4731)
@@ -17,4 +17,5 @@
 psS32 main()
 {
+    psLogSetFormat("HLNM");
     psS32 testStatus = true;
     psS32 memLeaks=0;
Index: /trunk/psLib/test/math/tst_psFunc04.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc04.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc04.c	(revision 4731)
@@ -129,5 +129,7 @@
 psS32 main()
 {
+    psLogSetFormat("HLNM");
     t00();
+    // XXX: Why is this commented?
     //    t01();
 }
Index: /trunk/psLib/test/math/tst_psFunc05.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc05.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc05.c	(revision 4731)
@@ -20,4 +20,5 @@
 psS32 main()
 {
+    psLogSetFormat("HLNM");
     psS32 testStatus = true;
     psS32 memLeaks=0;
Index: /trunk/psLib/test/math/tst_psFunc08.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc08.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc08.c	(revision 4731)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-07-20 01:21:13 $
+*  @version  $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-08-08 21:44:09 $
 *
 *  XXX: Probably should test single- and multi-dimensional polynomials in
@@ -46,4 +46,5 @@
 psS32 main(psS32 argc, char* argv[])
 {
+    psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
 
Index: /trunk/psLib/test/math/tst_psFunc09.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc09.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc09.c	(revision 4731)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-07-20 01:21:13 $
+*  @version  $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-08-08 21:44:09 $
 *
 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -75,4 +75,5 @@
 psS32 main(psS32 argc, char* argv[])
 {
+    psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
 
Index: /trunk/psLib/test/math/tst_psFunc10.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc10.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc10.c	(revision 4731)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-07-20 01:21:13 $
+*  @version  $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-08-08 21:44:09 $
 *
 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -126,4 +126,5 @@
 psS32 main(psS32 argc, char* argv[])
 {
+    psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
 
Index: /trunk/psLib/test/math/tst_psFunc11.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc11.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psFunc11.c	(revision 4731)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.2 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-07-20 01:21:13 $
+*  @version  $Revision: 1.3 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-08-08 21:44:09 $
 *
 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -368,4 +368,5 @@
 psS32 main(psS32 argc, char* argv[])
 {
+    psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
 
Index: /trunk/psLib/test/math/tst_psMinimize06.c
===================================================================
--- /trunk/psLib/test/math/tst_psMinimize06.c	(revision 4730)
+++ /trunk/psLib/test/math/tst_psMinimize06.c	(revision 4731)
@@ -6,9 +6,8 @@
 #include "psTest.h"
 #include <math.h>
-#define NUM_ITERATIONS 10000
+#define NUM_ITERATIONS 100
 #define ERR_TOL 0.0
-#define N 20
-#define MIN_VALUE 5.0
-#define NUM_PARAMS 3
+#define NUM_DATA_POINTS 20
+#define NUM_PARAMS 5
 float expectedParm[NUM_PARAMS];
 psS32 testStatus = true;
@@ -16,22 +15,30 @@
 /*****************************************************************************
 myFunc():
-    sum = (param[0] * x[0]) + 
-          (param[1] * x[1]) +
-          ...
+    sum = param[0] + x[0] * x[1] +
+          param[1] * x[0] + 
+          param[2] * x[0]^2 +
+          param[3] * x[1] + 
+          param[4] * x[1]^2
+ 
  *****************************************************************************/
-psF64 myFunc(psVector *deriv,
+psF32 myFunc(psVector *deriv,
              psVector *params,
              psVector *x)
 {
-    if ((deriv == NULL) ||
-            (params == NULL)) {
+    if ((deriv == NULL) || (params == NULL)) {
         psError(PS_ERR_UNKNOWN, true, "deriv or params is NULL.\n");
     }
 
-    psF64 sum = 0.0;
-    for (psS32 i=0 ; i < params->n ; i++) {
-        sum += (params->data.F32[i] * x->data.F32[i]);
-        deriv->data.F32[i] = params->data.F32[i];
-    }
+    psF32 sum = (params->data.F32[0] * x->data.F32[0] * x->data.F32[1]) +
+                (params->data.F32[1] * x->data.F32[0]) +
+                (params->data.F32[2] * PS_SQR(x->data.F32[0])) +
+                (params->data.F32[3] * x->data.F32[1]) +
+                (params->data.F32[4] * PS_SQR(x->data.F32[1]));
+
+    deriv->data.F32[0] = x->data.F32[0] * x->data.F32[1];
+    deriv->data.F32[1] = x->data.F32[0];
+    deriv->data.F32[2] = PS_SQR(x->data.F32[0]);
+    deriv->data.F32[3] = x->data.F32[1];
+    deriv->data.F32[4] = PS_SQR(x->data.F32[1]);
 
     return(sum);
@@ -42,33 +49,27 @@
 {
     psS32 currentId = psMemGetId();
-    psS32 memLeaks = 0;
-    psS32 i = 0;
-    psArray *myCoords;
-    psVector *myParams;
-    psImage *myCovar;
-    psMinimization *min;
-    psVector *y;
-
     psTraceSetLevel(".psLib", 0);
     /**************************************************************************
      *************************************************************************/
-    min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL);
-    myCovar = psImageAlloc(NUM_PARAMS, NUM_PARAMS, PS_TYPE_F32);
-    myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
-    myCoords = psArrayAlloc(N);
-    y = psVectorAlloc(N, PS_TYPE_F32);
+    psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL);
+    psImage *myCovar = psImageAlloc(NUM_PARAMS, NUM_PARAMS, PS_TYPE_F32);
+    psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
+    psVector *myDerivs = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
+    psArray *myCoords = psArrayAlloc(NUM_DATA_POINTS);
+    psVector *y = psVectorAlloc(NUM_DATA_POINTS, PS_TYPE_F32);
 
-    for (i=0;i<N;i++) {
+    for (psS32 i=0;i<NUM_DATA_POINTS;i++) {
         myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
         ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10);
         ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) (i+3);
+        /*
+                printf("x[%d] is vector (%f, %f)\n", i, ((psVector *) (myCoords->data[i]))->data.F32[0],
+                                                        ((psVector *) (myCoords->data[i]))->data.F32[1]);
+        */
         y->data.F32[i] = (float) i;
     }
-    for (i=0;i<NUM_PARAMS;i++) {
+    for (psS32 i=0;i<NUM_PARAMS;i++) {
         expectedParm[i] = 2.42 + (float) (2 * i);
-        myParams->data.F32[i] = (float) i;
-        myParams->data.F32[i] = expectedParm[i] * 1.3;
-        myParams->data.F32[i] = 0.0;
-        myParams->data.F32[i] = (float) (5 + i);
+        myParams->data.F32[i] = (float) (2 * i);
     }
 
@@ -82,6 +83,10 @@
                      (psMinimizeLMChi2Func) myFunc);
 
-    printf("\nThe chi-squared is %f\n", min->value);
-    for (i=0;i<NUM_PARAMS;i++) {
+    printf("\nThe value of the function at the minimum is %f\n", min->value);
+    for (psS32 i=0;i<NUM_DATA_POINTS;i++) {
+        printf("The minimum for data point %d: %f\n", i, myFunc(myDerivs, myParams, (psVector *) myCoords->data[i]));
+    }
+
+    for (psS32 i=0;i<NUM_PARAMS;i++) {
         printf("Parameter %d at the minimum is %f (expected: %f)\n", i,
                myParams->data.F32[i], expectedParm[i]);
@@ -91,9 +96,10 @@
     psFree(myCovar);
     psFree(myParams);
+    psFree(myDerivs);
     psFree(myCoords);
     psFree(y);
 
     psMemCheckCorruption(1);
-    memLeaks = psMemCheckLeaks(currentId,NULL,NULL,false);
+    psS32 memLeaks = psMemCheckLeaks(currentId,NULL,NULL,false);
     if (0 != memLeaks) {
         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
