Index: /trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.c	(revision 1860)
+++ /trunk/psLib/src/dataManip/psFunctions.c	(revision 1861)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 04:56:40 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 06:12:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1661,5 +1661,4 @@
 
 /*****************************************************************************
-XXX: Ensure that domain[i+1] != domain[i]
  *****************************************************************************/
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
@@ -1681,6 +1680,12 @@
 
     tmp->domains = (float *) psAlloc((bounds->n) * sizeof(float));
+
     for (i=0;i<bounds->n;i++) {
         (tmp->domains)[i] = bounds->data.F32[i];
+        if (i<(bounds->n-1)) {
+            if (FLT_EPSILON < fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
+                // XXX: psErrorMsg(data points must be distinct)
+            }
+        }
     }
 
@@ -1697,4 +1702,6 @@
  
 XXX: Macro this for a few different types.
+ 
+XXX: name since we don't take psVectors as input.
  *****************************************************************************/
 int p_psVectorBinDisectF32(float *bins,
@@ -1867,5 +1874,8 @@
 
 
-// This is a
+/*****************************************************************************
+p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
 float p_ps1DInterpolateF32(float *domain,
                            float *range,
@@ -1910,5 +1920,7 @@
 order around the point x.
  
-XXX: This stuff does not work with a mask.
+XXX: This stuff does not currently work with a mask.
+ 
+XXX: nobody asked for us to generate this routine.
  *****************************************************************************/
 psScalar *p_psVectorInterpolate(psVector *domain,
@@ -1948,4 +1960,13 @@
 
 
+/*****************************************************************************
+psSpline1DEval(): this routine takes an existing spline of arbitrary order
+and an independent x value.  Each determines which spline that x corresponds
+to by doing a bracket disection on the domains of the spline data structure
+(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+by a call to the 1D polynomial functions.
+ 
+XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
+ *****************************************************************************/
 float psSpline1DEval(const psSpline1D *spline,
                      float x)
@@ -1985,58 +2006,2 @@
     return(tmpVector);
 }
-
-
-
-/*****************************************************************************
-psSpline1DGen(): This routine will take an existing spline data structure,
-along with a set of data values for each of the domains, and fit splines of
-the specified order (currently, linear only), and set the coefficients in the
-appropriate spline polynomials.  This function is not part of the API in the
-latest SDR, but I'm guessing it will be, and I need it to generate test
-cases, so I included it here.
- *****************************************************************************/
-
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data)
-{
-    int i;
-    float slope;
-
-    psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-            "---- Calling psSpline1DGen()\n");
-
-    if (data->n != (1 + spline->n)) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "data size / spline size mismatch (%d %d)\n",
-                 data->n, spline->n);
-        return(NULL);
-    }
-    // XXX: verify your math
-    if (2 == (spline->spline[0])->n) {
-        for (i=0;i<spline->n;i++) {
-            slope = (data->data.F32[i+1] - data->data.F32[i]) /
-                    (spline->domains[i+1] - spline->domains[i]);
-            (spline->spline[i])->coeff[0] = data->data.F32[i] -
-                                            (slope * spline->domains[i]);
-            //printf("HMMM (%f, %f, %f)\n", data->data.F32[i], slope, spline->domains[i]);
-
-            (spline->spline[i])->coeff[1] = slope;
-            psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                    "---- spline %d coeffs are (%f, %f)\n", i,
-                    (spline->spline[i])->coeff[0],
-                    (spline->spline[i])->coeff[1]);
-        }
-        psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                "---- Exiting psSpline1DGen()\n");
-        return((psSpline1D *) spline);
-    } else if (4 == (spline->spline[0])->n) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Cubic splines have not been implemented.");
-        return(NULL);
-    } else {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n-1);
-        return(NULL);
-    }
-}
Index: /trunk/psLib/src/dataManip/psFunctions.h
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.h	(revision 1860)
+++ /trunk/psLib/src/dataManip/psFunctions.h	(revision 1861)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-23 04:56:41 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-23 06:12:22 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -404,7 +404,4 @@
                                const psSpline1D *spline);
 
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data);
-
 int p_psVectorBinDisectF32(float *bins,
                            int numBins,
Index: /trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.c	(revision 1860)
+++ /trunk/psLib/src/dataManip/psMinimize.c	(revision 1861)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 05:43:25 $
+ *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 06:12:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -345,11 +345,11 @@
 
             (mySpline->spline[i])->coeff[1] = slope;
-            psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
+            psTrace(".psLib.dataManip.psMinimize.psVectorFitSpline1D", 4,
                     "---- mySpline %d coeffs are (%f, %f)\n", i,
                     (mySpline->spline[i])->coeff[0],
                     (mySpline->spline[i])->coeff[1]);
         }
-        psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                "---- Exiting psSpline1DGen()\n");
+        psTrace(".psLib.dataManip.psMinimize.psVectorFitSpline1D", 4,
+                "---- Exiting psVectorFitSpline1D()()\n");
         return((psSpline1D *) mySpline);
     }
Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 1860)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 1861)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 05:43:25 $
+ *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 06:12:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -345,11 +345,11 @@
 
             (mySpline->spline[i])->coeff[1] = slope;
-            psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
+            psTrace(".psLib.dataManip.psMinimize.psVectorFitSpline1D", 4,
                     "---- mySpline %d coeffs are (%f, %f)\n", i,
                     (mySpline->spline[i])->coeff[0],
                     (mySpline->spline[i])->coeff[1]);
         }
-        psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                "---- Exiting psSpline1DGen()\n");
+        psTrace(".psLib.dataManip.psMinimize.psVectorFitSpline1D", 4,
+                "---- Exiting psVectorFitSpline1D()()\n");
         return((psSpline1D *) mySpline);
     }
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 1860)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 1861)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 04:56:40 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 06:12:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1661,5 +1661,4 @@
 
 /*****************************************************************************
-XXX: Ensure that domain[i+1] != domain[i]
  *****************************************************************************/
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
@@ -1681,6 +1680,12 @@
 
     tmp->domains = (float *) psAlloc((bounds->n) * sizeof(float));
+
     for (i=0;i<bounds->n;i++) {
         (tmp->domains)[i] = bounds->data.F32[i];
+        if (i<(bounds->n-1)) {
+            if (FLT_EPSILON < fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
+                // XXX: psErrorMsg(data points must be distinct)
+            }
+        }
     }
 
@@ -1697,4 +1702,6 @@
  
 XXX: Macro this for a few different types.
+ 
+XXX: name since we don't take psVectors as input.
  *****************************************************************************/
 int p_psVectorBinDisectF32(float *bins,
@@ -1867,5 +1874,8 @@
 
 
-// This is a
+/*****************************************************************************
+p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
 float p_ps1DInterpolateF32(float *domain,
                            float *range,
@@ -1910,5 +1920,7 @@
 order around the point x.
  
-XXX: This stuff does not work with a mask.
+XXX: This stuff does not currently work with a mask.
+ 
+XXX: nobody asked for us to generate this routine.
  *****************************************************************************/
 psScalar *p_psVectorInterpolate(psVector *domain,
@@ -1948,4 +1960,13 @@
 
 
+/*****************************************************************************
+psSpline1DEval(): this routine takes an existing spline of arbitrary order
+and an independent x value.  Each determines which spline that x corresponds
+to by doing a bracket disection on the domains of the spline data structure
+(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+by a call to the 1D polynomial functions.
+ 
+XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
+ *****************************************************************************/
 float psSpline1DEval(const psSpline1D *spline,
                      float x)
@@ -1985,58 +2006,2 @@
     return(tmpVector);
 }
-
-
-
-/*****************************************************************************
-psSpline1DGen(): This routine will take an existing spline data structure,
-along with a set of data values for each of the domains, and fit splines of
-the specified order (currently, linear only), and set the coefficients in the
-appropriate spline polynomials.  This function is not part of the API in the
-latest SDR, but I'm guessing it will be, and I need it to generate test
-cases, so I included it here.
- *****************************************************************************/
-
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data)
-{
-    int i;
-    float slope;
-
-    psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-            "---- Calling psSpline1DGen()\n");
-
-    if (data->n != (1 + spline->n)) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "data size / spline size mismatch (%d %d)\n",
-                 data->n, spline->n);
-        return(NULL);
-    }
-    // XXX: verify your math
-    if (2 == (spline->spline[0])->n) {
-        for (i=0;i<spline->n;i++) {
-            slope = (data->data.F32[i+1] - data->data.F32[i]) /
-                    (spline->domains[i+1] - spline->domains[i]);
-            (spline->spline[i])->coeff[0] = data->data.F32[i] -
-                                            (slope * spline->domains[i]);
-            //printf("HMMM (%f, %f, %f)\n", data->data.F32[i], slope, spline->domains[i]);
-
-            (spline->spline[i])->coeff[1] = slope;
-            psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                    "---- spline %d coeffs are (%f, %f)\n", i,
-                    (spline->spline[i])->coeff[0],
-                    (spline->spline[i])->coeff[1]);
-        }
-        psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                "---- Exiting psSpline1DGen()\n");
-        return((psSpline1D *) spline);
-    } else if (4 == (spline->spline[0])->n) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Cubic splines have not been implemented.");
-        return(NULL);
-    } else {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n-1);
-        return(NULL);
-    }
-}
Index: /trunk/psLib/src/math/psPolynomial.h
===================================================================
--- /trunk/psLib/src/math/psPolynomial.h	(revision 1860)
+++ /trunk/psLib/src/math/psPolynomial.h	(revision 1861)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-23 04:56:41 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-23 06:12:22 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -404,7 +404,4 @@
                                const psSpline1D *spline);
 
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data);
-
 int p_psVectorBinDisectF32(float *bins,
                            int numBins,
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 1860)
+++ /trunk/psLib/src/math/psSpline.c	(revision 1861)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 04:56:40 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-23 06:12:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1661,5 +1661,4 @@
 
 /*****************************************************************************
-XXX: Ensure that domain[i+1] != domain[i]
  *****************************************************************************/
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
@@ -1681,6 +1680,12 @@
 
     tmp->domains = (float *) psAlloc((bounds->n) * sizeof(float));
+
     for (i=0;i<bounds->n;i++) {
         (tmp->domains)[i] = bounds->data.F32[i];
+        if (i<(bounds->n-1)) {
+            if (FLT_EPSILON < fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
+                // XXX: psErrorMsg(data points must be distinct)
+            }
+        }
     }
 
@@ -1697,4 +1702,6 @@
  
 XXX: Macro this for a few different types.
+ 
+XXX: name since we don't take psVectors as input.
  *****************************************************************************/
 int p_psVectorBinDisectF32(float *bins,
@@ -1867,5 +1874,8 @@
 
 
-// This is a
+/*****************************************************************************
+p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
 float p_ps1DInterpolateF32(float *domain,
                            float *range,
@@ -1910,5 +1920,7 @@
 order around the point x.
  
-XXX: This stuff does not work with a mask.
+XXX: This stuff does not currently work with a mask.
+ 
+XXX: nobody asked for us to generate this routine.
  *****************************************************************************/
 psScalar *p_psVectorInterpolate(psVector *domain,
@@ -1948,4 +1960,13 @@
 
 
+/*****************************************************************************
+psSpline1DEval(): this routine takes an existing spline of arbitrary order
+and an independent x value.  Each determines which spline that x corresponds
+to by doing a bracket disection on the domains of the spline data structure
+(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+by a call to the 1D polynomial functions.
+ 
+XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
+ *****************************************************************************/
 float psSpline1DEval(const psSpline1D *spline,
                      float x)
@@ -1985,58 +2006,2 @@
     return(tmpVector);
 }
-
-
-
-/*****************************************************************************
-psSpline1DGen(): This routine will take an existing spline data structure,
-along with a set of data values for each of the domains, and fit splines of
-the specified order (currently, linear only), and set the coefficients in the
-appropriate spline polynomials.  This function is not part of the API in the
-latest SDR, but I'm guessing it will be, and I need it to generate test
-cases, so I included it here.
- *****************************************************************************/
-
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data)
-{
-    int i;
-    float slope;
-
-    psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-            "---- Calling psSpline1DGen()\n");
-
-    if (data->n != (1 + spline->n)) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "data size / spline size mismatch (%d %d)\n",
-                 data->n, spline->n);
-        return(NULL);
-    }
-    // XXX: verify your math
-    if (2 == (spline->spline[0])->n) {
-        for (i=0;i<spline->n;i++) {
-            slope = (data->data.F32[i+1] - data->data.F32[i]) /
-                    (spline->domains[i+1] - spline->domains[i]);
-            (spline->spline[i])->coeff[0] = data->data.F32[i] -
-                                            (slope * spline->domains[i]);
-            //printf("HMMM (%f, %f, %f)\n", data->data.F32[i], slope, spline->domains[i]);
-
-            (spline->spline[i])->coeff[1] = slope;
-            psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                    "---- spline %d coeffs are (%f, %f)\n", i,
-                    (spline->spline[i])->coeff[0],
-                    (spline->spline[i])->coeff[1]);
-        }
-        psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
-                "---- Exiting psSpline1DGen()\n");
-        return((psSpline1D *) spline);
-    } else if (4 == (spline->spline[0])->n) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Cubic splines have not been implemented.");
-        return(NULL);
-    } else {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "Don't know how to generate %d-order splines.",
-                 (spline->spline[0])->n-1);
-        return(NULL);
-    }
-}
Index: /trunk/psLib/src/math/psSpline.h
===================================================================
--- /trunk/psLib/src/math/psSpline.h	(revision 1860)
+++ /trunk/psLib/src/math/psSpline.h	(revision 1861)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-23 04:56:41 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-23 06:12:22 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -404,7 +404,4 @@
                                const psSpline1D *spline);
 
-psSpline1D *psSpline1DGen(const psSpline1D *spline,
-                          psVector *data);
-
 int p_psVectorBinDisectF32(float *bins,
                            int numBins,
Index: /trunk/psLib/test/dataManip/tst_psFunc04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 1860)
+++ /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 1861)
@@ -2,5 +2,5 @@
     This routine must ensure that the psSpline1DEval() function works
     properly.  It creates a spline with psSpline1DAlloc(), creates a set of
-    data values, sets the spline polynomials with psSpline1DGen(), then
+    data values, sets the spline polynomials with psVectorFitSpline1D(), then
     calls psSpline1DEval() on new data values and ensures that the results
     are correct.
@@ -41,6 +41,6 @@
         data->data.F32[i] = tmpSpline->domains[i];
     }
+    psVectorFitSpline1D(tmpSpline, data, data, NULL);
 
-    psSpline1DGen(tmpSpline, data);
     for (i=0;i<N+1;i++) {
         x = 0.5 + (float) i+1;
Index: /trunk/psLib/test/dataManip/tst_psFunc05.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc05.c	(revision 1860)
+++ /trunk/psLib/test/dataManip/tst_psFunc05.c	(revision 1861)
@@ -2,5 +2,5 @@
     This routine must ensure that the psSpline1DEval() function works
     properly.  It creates a spline with psSpline1DAlloc(), creates a set of
-    data values, sets the spline polynomials with psSpline1DGen(), then
+    data values, sets the spline polynomials with psVectorFitSpline1D(), then
     calls psSpline1DEval() on new data values and ensures that the results
     are correct.
@@ -44,5 +44,5 @@
     }
 
-    psSpline1DGen(tmpSpline, data);
+    psVectorFitSpline1D(tmpSpline, data, data, NULL);
 
     for (i=0;i<N+1;i++) {
Index: /trunk/psLib/test/dataManip/tst_psFunc07.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 1860)
+++ /trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 1861)
@@ -1,10 +1,12 @@
 /*****************************************************************************
-    This routine must ensure that the psSpline1DEval() function works
-    properly.  It creates a spline with psSpline1DAlloc(), creates a set of
-    data values, sets the spline polynomials with psSpline1DGen(), then
-    calls psSpline1DEval() on new data values and ensures that the results
-    are correct.
+This routine must ensure that the psVectorFitSpline1D() function works
+properly.  It creates a spline with psSpline1DAlloc(), creates a set of data
+values, sets the spline polynomials with psVectorFitSpline1D(), then calls
+psSpline1DEval() on new data values and ensures that the results are correct.
  
-    XXX: figure out the memory deallocator
+XXX: figure out the memory deallocator
+ 
+XXX: The interpolated values are not all that good.  However, they do agree
+with the NR version of the code.
  *****************************************************************************/
 #include <stdio.h>
