Index: /trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.c	(revision 1774)
+++ /trunk/psLib/src/dataManip/psFunctions.c	(revision 1775)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-09 23:39:36 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1593,11 +1593,15 @@
     float width;
 
+    if (fabs(max-min) < FLT_EPSILON) {
+        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
+        return(NULL);
+    }
+
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
-
     tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1626,8 +1630,9 @@
 
     numSplines = bounds->n - 1;
+    tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1668,5 +1673,6 @@
     mid = (max-min)/2;
 
-    while (min != max) {
+    while (min+1 < max) {
+        psTrace(".psLib.dataManip.psFunctions.VectorBinDisect", 4, "(min, max) is (%d, %d)\n", min, max);
         mid = (max-min)/2;
 
@@ -1721,6 +1727,6 @@
 
 
-psSpline1D *psSpline1DEGen(const psSpline1D *spline,
-                           psVector *data)
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data)
 {
     int i;
@@ -1734,5 +1740,5 @@
     }
     // XXX: verify your math
-    if (1 == (spline->spline[0])->n) {
+    if (2 == (spline->spline[0])->n) {
         for (i=0;i<spline->n;i++) {
             slope = (data->data.F32[i+1] - data->data.F32[i]) /
@@ -1742,9 +1748,6 @@
             (spline->spline[0])->coeff[1] = slope;
         }
-
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Linear splines have not been implemented.");
-        return(NULL);
-    } else if (3 == (spline->spline[0])->n) {
+        return((psSpline1D *) spline);
+    } else if (4 == (spline->spline[0])->n) {
         psLogMsg(__func__, PS_LOG_WARN,
                  "Cubic splines have not been implemented.");
@@ -1753,5 +1756,5 @@
         psLogMsg(__func__, PS_LOG_WARN,
                  "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n);
+                 (spline->spline[0])->n-1);
         return(NULL);
     }
Index: /trunk/psLib/src/dataManip/psFunctions.h
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.h	(revision 1774)
+++ /trunk/psLib/src/dataManip/psFunctions.h	(revision 1775)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-08 06:04:10 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-10 02:52:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -402,4 +402,8 @@
                                const psSpline1D *spline);
 
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data);
+
+
 /* \} */// End of MathGroup Functions
 
Index: /trunk/psLib/src/dataManip/psMatrix.c
===================================================================
--- /trunk/psLib/src/dataManip/psMatrix.c	(revision 1774)
+++ /trunk/psLib/src/dataManip/psMatrix.c	(revision 1775)
@@ -21,6 +21,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-09 23:34:57 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -205,6 +205,6 @@
 }
 
-psVector* psMatrixLUSolve(psVector* outVector, const psImage* inImage, const psVector* inVector, const
-                          psVector* inPerm)
+psVector* psMatrixLUSolve(psVector* outVector, const psImage* inImage,
+                          const psVector* inVector, const psVector* inPerm)
 {
     int arraySize = 0;
Index: /trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.c	(revision 1774)
+++ /trunk/psLib/src/dataManip/psMinimize.c	(revision 1775)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-08 23:32:03 $
+ *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -846,6 +846,4 @@
 /******************************************************************************
 GUS
- 
-XXX: bug report for the psMatrix covar argument.
  *****************************************************************************/
 bool psMinimizeLM(psMinimization *min,
@@ -856,19 +854,79 @@
                   psMinimizeLMFunc func)
 {
-    /*
-        psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32);
-        psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32);
-        psVector *deriv;
-        int i;
-        int k;
-        float tmp;
-     
-        tmp = func(deriv, params, coords);
-        for (k=0;k<params->n;k++) {
-            beta->data.F32[k] = 0.0;
+    psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *perm = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *newParams = psVectorAlloc(params->n, PS_TYPE_F32);
+    psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psImage *A = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psImage *aOut = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *newDeriv = psVectorAlloc(params->n, PS_TYPE_F32);
+    int i;
+    int j;
+    int k;
+    float newValue;
+    float oldValue;
+    float lamda = 1.0;
+
+    min->lastDelta = -HUGE;
+    min->iter = 0;
+    min->value = func(deriv, params, coords);
+
+    while ((min->lastDelta > min->tol) &&
+            (min->iter < min->maxIter)) {
+
+        for (i=0;i<params->n;i++) {
+            beta->data.F32[i] = deriv->data.F32[i];
+        }
+
+        for (j=0;j<params->n;j++) {
+            for (k=0;k<params->n;k++) {
+                alpha->data.F32[j][k] = deriv->data.F32[j] * deriv->data.F32[j];
+            }
+        }
+        for (j=0;j<params->n;j++) {
+            for (k=0;k<params->n;k++) {
+                if (j != k) {
+                    A->data.F32[j][k] = alpha->data.F32[j][k];
+                } else {
+                    A->data.F32[j][k] = (1.0 + lamda) * alpha->data.F32[j][k];
+                }
+            }
+        }
+        aOut = psMatrixLUD(aOut, perm, A);
+        newParams = psMatrixLUSolve(newParams, aOut, beta, perm);
+
+        oldValue = min->value;
+        newValue = func(newDeriv, newParams, coords);
+        if (oldValue > newValue) {
+            min->lastDelta = oldValue - newValue;
+            min->value = newValue;
+
             for (i=0;i<params->n;i++) {
-                beta->data.F32[k]+= deriv
-            }
-    */
+                params->data.F32[i] = newParams->data.F32[i];
+                deriv->data.F32[i] = newDeriv->data.F32[i];
+            }
+            min->value = func(deriv, params, coords);
+
+            lamda*= 0.1;
+        } else {
+            lamda*= 10.0;
+        }
+        min->iter++;
+    }
+    psFree(beta);
+    psFree(perm);
+    psFree(newParams);
+    psFree(alpha);
+    psFree(A);
+    psFree(aOut);
+    psFree(deriv);
+    psFree(newDeriv);
+
+    if ((min->iter < min->maxIter) ||
+            (min->lastDelta <= min->tol)) {
+        return(true);
+    }
+
     return(false);
 }
Index: /trunk/psLib/src/math/psMatrix.c
===================================================================
--- /trunk/psLib/src/math/psMatrix.c	(revision 1774)
+++ /trunk/psLib/src/math/psMatrix.c	(revision 1775)
@@ -21,6 +21,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-09 23:34:57 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -205,6 +205,6 @@
 }
 
-psVector* psMatrixLUSolve(psVector* outVector, const psImage* inImage, const psVector* inVector, const
-                          psVector* inPerm)
+psVector* psMatrixLUSolve(psVector* outVector, const psImage* inImage,
+                          const psVector* inVector, const psVector* inPerm)
 {
     int arraySize = 0;
Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 1774)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 1775)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-08 23:32:03 $
+ *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -846,6 +846,4 @@
 /******************************************************************************
 GUS
- 
-XXX: bug report for the psMatrix covar argument.
  *****************************************************************************/
 bool psMinimizeLM(psMinimization *min,
@@ -856,19 +854,79 @@
                   psMinimizeLMFunc func)
 {
-    /*
-        psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32);
-        psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32);
-        psVector *deriv;
-        int i;
-        int k;
-        float tmp;
-     
-        tmp = func(deriv, params, coords);
-        for (k=0;k<params->n;k++) {
-            beta->data.F32[k] = 0.0;
+    psVector *beta = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *perm = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *newParams = psVectorAlloc(params->n, PS_TYPE_F32);
+    psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psImage *A = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psImage *aOut = psImageAlloc(params->n, params->n, PS_TYPE_F32);
+    psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
+    psVector *newDeriv = psVectorAlloc(params->n, PS_TYPE_F32);
+    int i;
+    int j;
+    int k;
+    float newValue;
+    float oldValue;
+    float lamda = 1.0;
+
+    min->lastDelta = -HUGE;
+    min->iter = 0;
+    min->value = func(deriv, params, coords);
+
+    while ((min->lastDelta > min->tol) &&
+            (min->iter < min->maxIter)) {
+
+        for (i=0;i<params->n;i++) {
+            beta->data.F32[i] = deriv->data.F32[i];
+        }
+
+        for (j=0;j<params->n;j++) {
+            for (k=0;k<params->n;k++) {
+                alpha->data.F32[j][k] = deriv->data.F32[j] * deriv->data.F32[j];
+            }
+        }
+        for (j=0;j<params->n;j++) {
+            for (k=0;k<params->n;k++) {
+                if (j != k) {
+                    A->data.F32[j][k] = alpha->data.F32[j][k];
+                } else {
+                    A->data.F32[j][k] = (1.0 + lamda) * alpha->data.F32[j][k];
+                }
+            }
+        }
+        aOut = psMatrixLUD(aOut, perm, A);
+        newParams = psMatrixLUSolve(newParams, aOut, beta, perm);
+
+        oldValue = min->value;
+        newValue = func(newDeriv, newParams, coords);
+        if (oldValue > newValue) {
+            min->lastDelta = oldValue - newValue;
+            min->value = newValue;
+
             for (i=0;i<params->n;i++) {
-                beta->data.F32[k]+= deriv
-            }
-    */
+                params->data.F32[i] = newParams->data.F32[i];
+                deriv->data.F32[i] = newDeriv->data.F32[i];
+            }
+            min->value = func(deriv, params, coords);
+
+            lamda*= 0.1;
+        } else {
+            lamda*= 10.0;
+        }
+        min->iter++;
+    }
+    psFree(beta);
+    psFree(perm);
+    psFree(newParams);
+    psFree(alpha);
+    psFree(A);
+    psFree(aOut);
+    psFree(deriv);
+    psFree(newDeriv);
+
+    if ((min->iter < min->maxIter) ||
+            (min->lastDelta <= min->tol)) {
+        return(true);
+    }
+
     return(false);
 }
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 1774)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 1775)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-09 23:39:36 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1593,11 +1593,15 @@
     float width;
 
+    if (fabs(max-min) < FLT_EPSILON) {
+        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
+        return(NULL);
+    }
+
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
-
     tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1626,8 +1630,9 @@
 
     numSplines = bounds->n - 1;
+    tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1668,5 +1673,6 @@
     mid = (max-min)/2;
 
-    while (min != max) {
+    while (min+1 < max) {
+        psTrace(".psLib.dataManip.psFunctions.VectorBinDisect", 4, "(min, max) is (%d, %d)\n", min, max);
         mid = (max-min)/2;
 
@@ -1721,6 +1727,6 @@
 
 
-psSpline1D *psSpline1DEGen(const psSpline1D *spline,
-                           psVector *data)
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data)
 {
     int i;
@@ -1734,5 +1740,5 @@
     }
     // XXX: verify your math
-    if (1 == (spline->spline[0])->n) {
+    if (2 == (spline->spline[0])->n) {
         for (i=0;i<spline->n;i++) {
             slope = (data->data.F32[i+1] - data->data.F32[i]) /
@@ -1742,9 +1748,6 @@
             (spline->spline[0])->coeff[1] = slope;
         }
-
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Linear splines have not been implemented.");
-        return(NULL);
-    } else if (3 == (spline->spline[0])->n) {
+        return((psSpline1D *) spline);
+    } else if (4 == (spline->spline[0])->n) {
         psLogMsg(__func__, PS_LOG_WARN,
                  "Cubic splines have not been implemented.");
@@ -1753,5 +1756,5 @@
         psLogMsg(__func__, PS_LOG_WARN,
                  "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n);
+                 (spline->spline[0])->n-1);
         return(NULL);
     }
Index: /trunk/psLib/src/math/psPolynomial.h
===================================================================
--- /trunk/psLib/src/math/psPolynomial.h	(revision 1774)
+++ /trunk/psLib/src/math/psPolynomial.h	(revision 1775)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-08 06:04:10 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-10 02:52:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -402,4 +402,8 @@
                                const psSpline1D *spline);
 
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data);
+
+
 /* \} */// End of MathGroup Functions
 
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 1774)
+++ /trunk/psLib/src/math/psSpline.c	(revision 1775)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-09 23:39:36 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-10 02:52:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1593,11 +1593,15 @@
     float width;
 
+    if (fabs(max-min) < FLT_EPSILON) {
+        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
+        return(NULL);
+    }
+
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
-
     tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1626,8 +1630,9 @@
 
     numSplines = bounds->n - 1;
+    tmp->n = numSplines;
 
     tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     for (i=0;i<numSplines;i++) {
-        (tmp->spline)[i] = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
+        (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
     }
 
@@ -1668,5 +1673,6 @@
     mid = (max-min)/2;
 
-    while (min != max) {
+    while (min+1 < max) {
+        psTrace(".psLib.dataManip.psFunctions.VectorBinDisect", 4, "(min, max) is (%d, %d)\n", min, max);
         mid = (max-min)/2;
 
@@ -1721,6 +1727,6 @@
 
 
-psSpline1D *psSpline1DEGen(const psSpline1D *spline,
-                           psVector *data)
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data)
 {
     int i;
@@ -1734,5 +1740,5 @@
     }
     // XXX: verify your math
-    if (1 == (spline->spline[0])->n) {
+    if (2 == (spline->spline[0])->n) {
         for (i=0;i<spline->n;i++) {
             slope = (data->data.F32[i+1] - data->data.F32[i]) /
@@ -1742,9 +1748,6 @@
             (spline->spline[0])->coeff[1] = slope;
         }
-
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Linear splines have not been implemented.");
-        return(NULL);
-    } else if (3 == (spline->spline[0])->n) {
+        return((psSpline1D *) spline);
+    } else if (4 == (spline->spline[0])->n) {
         psLogMsg(__func__, PS_LOG_WARN,
                  "Cubic splines have not been implemented.");
@@ -1753,5 +1756,5 @@
         psLogMsg(__func__, PS_LOG_WARN,
                  "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n);
+                 (spline->spline[0])->n-1);
         return(NULL);
     }
Index: /trunk/psLib/src/math/psSpline.h
===================================================================
--- /trunk/psLib/src/math/psSpline.h	(revision 1774)
+++ /trunk/psLib/src/math/psSpline.h	(revision 1775)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-08 06:04:10 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-10 02:52:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -402,4 +402,8 @@
                                const psSpline1D *spline);
 
+psSpline1D *psSpline1DGen(const psSpline1D *spline,
+                          psVector *data);
+
+
 /* \} */// End of MathGroup Functions
 
Index: /trunk/psLib/test/dataManip/Makefile
===================================================================
--- /trunk/psLib/test/dataManip/Makefile	(revision 1774)
+++ /trunk/psLib/test/dataManip/Makefile	(revision 1775)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/sysUtils
 ##
-##  $Revision: 1.35 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-07-28 02:50:38 $
+##  $Revision: 1.36 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-09-10 02:55:20 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,4 +22,7 @@
 tst_psFunc00 \
 tst_psFunc01 \
+tst_psFunc02 \
+tst_psFunc03 \
+tst_psFunc04 \
 tst_psHist00 \
 tst_psHist01 \
Index: /trunk/psLib/test/dataManip/tst_psFunc02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc02.c	(revision 1775)
+++ /trunk/psLib/test/dataManip/tst_psFunc02.c	(revision 1775)
@@ -0,0 +1,292 @@
+/*****************************************************************************
+    This routine must ensure that the psSpline1DAlloc() function properly
+    allocates the spline data structure.
+ 
+    XXX: figure out the memory deallocator
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psFunctions.h"
+
+#define N 10
+
+int main()
+{
+    int testStatus = true;
+    int memLeaks=0;
+    int i;
+    //    int  currentId = psMemGetId();
+    psSpline1D *tmpSpline;
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 1, 1.0, 10.0);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 2) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        printf("psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 1, 1.0, 1.0);
+
+    if (tmpSpline != NULL) {
+        printf("ERROR: allocated psSpline1D data structure when min==max\n");
+        testStatus = false;
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 1, 1.0, -1.0);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 2) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        printf("psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 3, 1.0, 10.0);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 4) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        printf("psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 3, 1.0, 1.0);
+
+    if (tmpSpline != NULL) {
+        printf("ERROR: allocated psSpline1D data structure when min==max\n");
+        testStatus = false;
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    tmpSpline = psSpline1DAlloc(N, 3, 1.0, -1.0);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 4) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        printf("psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/dataManip/tst_psFunc03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc03.c	(revision 1775)
+++ /trunk/psLib/test/dataManip/tst_psFunc03.c	(revision 1775)
@@ -0,0 +1,145 @@
+/*****************************************************************************
+    This routine must ensure that the psSpline1DAllocGeneric() function properly
+    allocates the spline data structure.
+ 
+    XXX: figure out the memory deallocator
+    XXX: test bounds?
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psFunctions.h"
+
+#define N 10
+
+int main()
+{
+    int testStatus = true;
+    int memLeaks=0;
+    int i;
+    //    int  currentId = psMemGetId();
+    psSpline1D *tmpSpline;
+    psVector *bounds;
+
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+    bounds = psVectorAlloc(N+1, PS_TYPE_F32);
+    for (i=0;i<N+1;i++) {
+        bounds->data.F32[i] = (float) (3 * i);
+    }
+
+    tmpSpline = psSpline1DAllocGeneric(bounds, 1);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 2) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        if (tmpSpline->domains[i] != bounds->data.F32[i]) {
+            printf("ERROR: psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+        }
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+    bounds = psVectorAlloc(N+1, PS_TYPE_F32);
+    for (i=0;i<N+1;i++) {
+        bounds->data.F32[i] = (float) (3 * i);
+    }
+
+    tmpSpline = psSpline1DAllocGeneric(bounds, 3);
+    if (tmpSpline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D data structure\n");
+        testStatus = false;
+    }
+    if (tmpSpline->spline == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->spline data structure\n");
+        testStatus = false;
+    }
+
+    if (tmpSpline->n != N) {
+        printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n);
+        testStatus = false;
+    }
+
+    for (i=0;i<N;i++) {
+        if (tmpSpline->spline[i] == NULL) {
+            printf("ERROR: Could not allocate spline %d\n", i);
+            testStatus = false;
+        }
+        if ((tmpSpline->spline[i])->n != 4) {
+            printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n);
+            testStatus = false;
+        }
+    }
+
+    if (tmpSpline->domains == NULL) {
+        printf("ERROR: Could not allocate psSpline1D->domains data structure\n");
+        testStatus = false;
+    }
+
+    for (i=0;i<N+1;i++) {
+        if (tmpSpline->domains[i] != bounds->data.F32[i]) {
+            printf("ERROR: psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]);
+        }
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/dataManip/tst_psFunc04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 1775)
+++ /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 1775)
@@ -0,0 +1,58 @@
+/*****************************************************************************
+    This routine must ensure that the psSpline1DAlloc() function properly
+    allocates the spline data structure.
+ 
+    XXX: figure out the memory deallocator
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psMemory.h"
+#include "psFunctions.h"
+
+#define N 10
+
+int main()
+{
+    int testStatus = true;
+    int memLeaks=0;
+    int i;
+    float tmp;
+    //    int  currentId = psMemGetId();
+    psSpline1D *tmpSpline;
+    psVector *data;
+
+    psTraceSetLevel(".", 9);
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+    data = psVectorAlloc(N+1, PS_TYPE_F32);
+    tmpSpline = psSpline1DAlloc(N, 1, 1.0, 10.0);
+
+    for (i=0;i<N+1;i++) {
+        data->data.F32[i] = (float) tmpSpline->domains[i];
+    }
+
+    psSpline1DGen(tmpSpline, data);
+    for (i=0;i<N+1;i++) {
+        tmp = psSpline1DEval(tmpSpline, (float) i+1);
+        printf("%f -> %f\n", (float) i+1, tmp);
+    }
+
+    psFree(tmpSpline);
+    psMemCheckCorruption(1);
+    //    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
