Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 1906)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 1907)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 23:05:07 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -48,4 +48,23 @@
 }
 
+/** Preprocessor macro to generate error on a NULL image */
+#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
+if (NAME == NULL || NAME->data.V == NULL) {                                                         \
+    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
+}
+
+/** Preprocessor macro to generate error for zero length rows or columns */
+#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
+if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
+    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
+            NAME->numCols, NAME->numRows);                                                          \
+}
+
+/** Preprocessor macro to generate error on a NULL 1DPolynomial */
+#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
+if (NAME == NULL || NAME->coeff == NULL) {                                                         \
+    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
+}
+
 #define PS_PRINT_VECTOR(NAME) \
 for (int my_i=0;my_i<NAME->n;my_i++) { \
Index: /trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.c	(revision 1906)
+++ /trunk/psLib/src/dataManip/psFunctions.c	(revision 1907)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 23:05:07 $
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -111,5 +111,14 @@
 /*****************************************************************************/
 
-static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
+/*****************************************************************************
+CreateChebyshevPolys(n): this routine takes as input the required order n,
+and returns as output as a pointer to an array of n psPolynomial1D
+structures, corresponding to the first n Chebyshev polynomials.
+ 
+XXX: The output should be static since the Chebyshev polynomials might be
+used frequently and the data structure created here does not contain the
+outer coefficients of the Chebyshev polynomials.
+ *****************************************************************************/
+static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
 {
     psPolynomial1D **chebPolys = NULL;
@@ -430,8 +439,4 @@
     Polynomial coefficients will be accessed in [w][x][y][z] fashion.
  
-    XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
-    in polynomial evaluation.  If so, then all of the following polynomial
-    evaluation functions must be modified to do so.
- 
     XXX: Should the "coeffErr[]" should be used as well?
  *****************************************************************************/
@@ -502,4 +507,20 @@
     psFree(d);
     return(tmp);
+    /*
+        int n;
+        int i;
+        float tmp;
+        psPolynomial1D **chebPolys = NULL;
+     
+        n = myPoly->n;
+        chebPolys = CreateChebyshevPolys(n);
+     
+        tmp = 0.0;
+        for (i=0;i<myPoly->n;i++) {
+            tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        }
+        tmp-= (myPoly->coeff[0]/2.0);
+        return(tmp);
+    */
 }
 
Index: /trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.c	(revision 1906)
+++ /trunk/psLib/src/dataManip/psMinimize.c	(revision 1907)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-24 20:08:22 $
+ *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -53,41 +53,4 @@
 /* DEFINE STATEMENTS                                                         */
 /*****************************************************************************/
-
-/** Preprocessor macro to generate error on a NULL 1DPolynomial */
-#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
-if (NAME == NULL || NAME->coeff == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR(NAME)                                                          \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error for zero length vector */
-#define PS_CHECK_EMPTY_VECTOR(NAME)                                                          \
-if (NAME->n < 1) {                                                                                  \
-    psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
-}
-
-/** Preprocessor macro to generate error on differing size vectors */
-#define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2)                                                          \
-if (VEC1->n != VEC2->n) {               \
-    psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
-}
-
-/** Preprocessor macro to generate error on a NULL image */
-#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error for zero length rows or columns */
-#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
-if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
-    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
-            NAME->numCols, NAME->numRows);                                                          \
-}
 
 /*****************************************************************************/
@@ -692,4 +655,85 @@
 }
 
+
+/*****************************************************************************
+CreateChebyshevPolys(n): this routine takes as input the required order n,
+and returns as output as a pointer to an array of n psPolynomial1D
+structures, corresponding to the first n Chebyshev polynomials.
+ 
+XXX: The output should be static since the Chebyshev polynomials might be
+used frequently and the data structure created here does not contain the
+outer coefficients of the Chebyshev polynomials.
+ *****************************************************************************/
+static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
+{
+    psPolynomial1D **chebPolys = NULL;
+    int i = 0;
+    int j = 0;
+
+    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
+    for (i = 0; i < maxChebyPoly; i++) {
+        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
+    }
+
+    // Create the Chebyshev polynomials.
+    // Polynomial i has i-th order.
+    chebPolys[0]->coeff[0] = 1;
+    chebPolys[1]->coeff[1] = 1;
+    for (i = 2; i < maxChebyPoly; i++) {
+        for (j = 0; j < chebPolys[i - 1]->n; j++) {
+            chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
+        }
+        for (j = 0; j < chebPolys[i - 2]->n; j++) {
+            chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
+        }
+    }
+
+    return (chebPolys);
+}
+
+
+
+psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly,
+        const psVector* restrict x,
+        const psVector* restrict y,
+        const psVector* restrict yErr)
+{
+    int j;
+    int k;
+    int n = x->n;
+    psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n);
+    ;
+    float fac;
+    float sum;
+    /*
+        fac = 2.0/((float) n);
+        for (j=0;j<n;j++) {
+            sum = 0.0;
+            for (k=0;k<n;k++) {
+                sum+= y->data.F64[k] *
+                      cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n)); 
+    //            sum+= y->data.F64[k] *
+    //                  cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) *
+    //                  cos(M_PI * (-0.5 + ((float) k)) / ((float) n)); 
+     
+            }
+            myPoly->coeff[j] = fac * sum;
+     
+        }
+        return(myPoly);
+    */
+
+    fac = 2.0/((float) n);
+    for (j=0;j<myPoly->n;j++) {
+        sum = 0.0;
+        for (k=1;k<n;k++) {
+            sum+= (y->data.F64[k] *
+                   psPolynomial1DEval((float) x->data.F64[k], chebPolys[j]));
+        }
+        myPoly->coeff[j] = fac * sum;
+    }
+    return(myPoly);
+}
+
 /******************************************************************************
 psVectorFitPolynomial1D():  This routine must fit a polynomial of degree
@@ -704,4 +748,7 @@
  
 XXX: Must do: if yErr==NULL, set all errors equal.
+ 
+XXX: type is currently ignored.  Must implement this for Chebyshev
+polynomials.
  *****************************************************************************/
 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,
@@ -710,4 +757,11 @@
                                         const psVector* restrict yErr)
 {
+    // XXX: Create a p_psVectorFitPolynomial1DOrd() function.  Here, we
+    // should only be calling that or the Cheby function.
+
+    if (myPoly->type == PS_POLYNOMIAL_CHEB) {
+        return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr));
+    }
+
     int polyOrder = myPoly->n;
     psImage* A = NULL;
Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 1906)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 1907)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:37:48 $
+ *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -858,4 +858,35 @@
     for (i = 0; i < myData->n; i++) {
         myData->data.F32[i] = (myData->data.F32[i] - min) / range;
+    }
+}
+
+/*****************************************************************************
+p_psNormalizeVectorF64(myData): this is a private function which normalizes the
+elements of a vector to a range between -1.0 and 1.0.
+ 
+XXX: incorporate this into above
+ 
+XXX: 0-1 or -1:1?
+ *****************************************************************************/
+void p_psNormalizeVectorF64(psVector* myData)
+{
+    float min = (float)HUGE;
+    float max = (float)-HUGE;
+    float range = 0.0;
+    int i = 0;
+
+    for (i = 0; i < myData->n; i++) {
+        if (myData->data.F64[i] < min) {
+            min = myData->data.F64[i];
+        }
+        if (myData->data.F64[i] > max) {
+            max = myData->data.F64[i];
+        }
+    }
+
+    range = max - min;
+    for (i = 0; i < myData->n; i++) {
+        myData->data.F64[i] = -1.0 + 2.0 *
+                              ((myData->data.F64[i] - min) / range);
     }
 }
Index: /trunk/psLib/src/dataManip/psStats.h
===================================================================
--- /trunk/psLib/src/dataManip/psStats.h	(revision 1906)
+++ /trunk/psLib/src/dataManip/psStats.h	(revision 1907)
@@ -10,6 +10,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 19:11:01 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -174,4 +174,9 @@
 );
 
+
+void p_psNormalizeVector(psVector* myData);
+void p_psNormalizeVectorF64(psVector* myData);
+
+
 /// @}
 
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 1906)
+++ /trunk/psLib/src/math/psConstants.h	(revision 1907)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 23:05:07 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -48,4 +48,23 @@
 }
 
+/** Preprocessor macro to generate error on a NULL image */
+#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
+if (NAME == NULL || NAME->data.V == NULL) {                                                         \
+    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
+}
+
+/** Preprocessor macro to generate error for zero length rows or columns */
+#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
+if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
+    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
+            NAME->numCols, NAME->numRows);                                                          \
+}
+
+/** Preprocessor macro to generate error on a NULL 1DPolynomial */
+#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
+if (NAME == NULL || NAME->coeff == NULL) {                                                         \
+    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
+}
+
 #define PS_PRINT_VECTOR(NAME) \
 for (int my_i=0;my_i<NAME->n;my_i++) { \
Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 1906)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 1907)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-24 20:08:22 $
+ *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -53,41 +53,4 @@
 /* DEFINE STATEMENTS                                                         */
 /*****************************************************************************/
-
-/** Preprocessor macro to generate error on a NULL 1DPolynomial */
-#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
-if (NAME == NULL || NAME->coeff == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR(NAME)                                                          \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error for zero length vector */
-#define PS_CHECK_EMPTY_VECTOR(NAME)                                                          \
-if (NAME->n < 1) {                                                                                  \
-    psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
-}
-
-/** Preprocessor macro to generate error on differing size vectors */
-#define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2)                                                          \
-if (VEC1->n != VEC2->n) {               \
-    psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
-}
-
-/** Preprocessor macro to generate error on a NULL image */
-#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-}
-
-/** Preprocessor macro to generate error for zero length rows or columns */
-#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
-if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
-    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
-            NAME->numCols, NAME->numRows);                                                          \
-}
 
 /*****************************************************************************/
@@ -692,4 +655,85 @@
 }
 
+
+/*****************************************************************************
+CreateChebyshevPolys(n): this routine takes as input the required order n,
+and returns as output as a pointer to an array of n psPolynomial1D
+structures, corresponding to the first n Chebyshev polynomials.
+ 
+XXX: The output should be static since the Chebyshev polynomials might be
+used frequently and the data structure created here does not contain the
+outer coefficients of the Chebyshev polynomials.
+ *****************************************************************************/
+static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
+{
+    psPolynomial1D **chebPolys = NULL;
+    int i = 0;
+    int j = 0;
+
+    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
+    for (i = 0; i < maxChebyPoly; i++) {
+        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
+    }
+
+    // Create the Chebyshev polynomials.
+    // Polynomial i has i-th order.
+    chebPolys[0]->coeff[0] = 1;
+    chebPolys[1]->coeff[1] = 1;
+    for (i = 2; i < maxChebyPoly; i++) {
+        for (j = 0; j < chebPolys[i - 1]->n; j++) {
+            chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
+        }
+        for (j = 0; j < chebPolys[i - 2]->n; j++) {
+            chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
+        }
+    }
+
+    return (chebPolys);
+}
+
+
+
+psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly,
+        const psVector* restrict x,
+        const psVector* restrict y,
+        const psVector* restrict yErr)
+{
+    int j;
+    int k;
+    int n = x->n;
+    psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n);
+    ;
+    float fac;
+    float sum;
+    /*
+        fac = 2.0/((float) n);
+        for (j=0;j<n;j++) {
+            sum = 0.0;
+            for (k=0;k<n;k++) {
+                sum+= y->data.F64[k] *
+                      cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n)); 
+    //            sum+= y->data.F64[k] *
+    //                  cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) *
+    //                  cos(M_PI * (-0.5 + ((float) k)) / ((float) n)); 
+     
+            }
+            myPoly->coeff[j] = fac * sum;
+     
+        }
+        return(myPoly);
+    */
+
+    fac = 2.0/((float) n);
+    for (j=0;j<myPoly->n;j++) {
+        sum = 0.0;
+        for (k=1;k<n;k++) {
+            sum+= (y->data.F64[k] *
+                   psPolynomial1DEval((float) x->data.F64[k], chebPolys[j]));
+        }
+        myPoly->coeff[j] = fac * sum;
+    }
+    return(myPoly);
+}
+
 /******************************************************************************
 psVectorFitPolynomial1D():  This routine must fit a polynomial of degree
@@ -704,4 +748,7 @@
  
 XXX: Must do: if yErr==NULL, set all errors equal.
+ 
+XXX: type is currently ignored.  Must implement this for Chebyshev
+polynomials.
  *****************************************************************************/
 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,
@@ -710,4 +757,11 @@
                                         const psVector* restrict yErr)
 {
+    // XXX: Create a p_psVectorFitPolynomial1DOrd() function.  Here, we
+    // should only be calling that or the Cheby function.
+
+    if (myPoly->type == PS_POLYNOMIAL_CHEB) {
+        return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr));
+    }
+
     int polyOrder = myPoly->n;
     psImage* A = NULL;
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 1906)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 1907)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 23:05:07 $
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -111,5 +111,14 @@
 /*****************************************************************************/
 
-static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
+/*****************************************************************************
+CreateChebyshevPolys(n): this routine takes as input the required order n,
+and returns as output as a pointer to an array of n psPolynomial1D
+structures, corresponding to the first n Chebyshev polynomials.
+ 
+XXX: The output should be static since the Chebyshev polynomials might be
+used frequently and the data structure created here does not contain the
+outer coefficients of the Chebyshev polynomials.
+ *****************************************************************************/
+static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
 {
     psPolynomial1D **chebPolys = NULL;
@@ -430,8 +439,4 @@
     Polynomial coefficients will be accessed in [w][x][y][z] fashion.
  
-    XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
-    in polynomial evaluation.  If so, then all of the following polynomial
-    evaluation functions must be modified to do so.
- 
     XXX: Should the "coeffErr[]" should be used as well?
  *****************************************************************************/
@@ -502,4 +507,20 @@
     psFree(d);
     return(tmp);
+    /*
+        int n;
+        int i;
+        float tmp;
+        psPolynomial1D **chebPolys = NULL;
+     
+        n = myPoly->n;
+        chebPolys = CreateChebyshevPolys(n);
+     
+        tmp = 0.0;
+        for (i=0;i<myPoly->n;i++) {
+            tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        }
+        tmp-= (myPoly->coeff[0]/2.0);
+        return(tmp);
+    */
 }
 
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 1906)
+++ /trunk/psLib/src/math/psSpline.c	(revision 1907)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 23:05:07 $
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -111,5 +111,14 @@
 /*****************************************************************************/
 
-static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
+/*****************************************************************************
+CreateChebyshevPolys(n): this routine takes as input the required order n,
+and returns as output as a pointer to an array of n psPolynomial1D
+structures, corresponding to the first n Chebyshev polynomials.
+ 
+XXX: The output should be static since the Chebyshev polynomials might be
+used frequently and the data structure created here does not contain the
+outer coefficients of the Chebyshev polynomials.
+ *****************************************************************************/
+static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
 {
     psPolynomial1D **chebPolys = NULL;
@@ -430,8 +439,4 @@
     Polynomial coefficients will be accessed in [w][x][y][z] fashion.
  
-    XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
-    in polynomial evaluation.  If so, then all of the following polynomial
-    evaluation functions must be modified to do so.
- 
     XXX: Should the "coeffErr[]" should be used as well?
  *****************************************************************************/
@@ -502,4 +507,20 @@
     psFree(d);
     return(tmp);
+    /*
+        int n;
+        int i;
+        float tmp;
+        psPolynomial1D **chebPolys = NULL;
+     
+        n = myPoly->n;
+        chebPolys = CreateChebyshevPolys(n);
+     
+        tmp = 0.0;
+        for (i=0;i<myPoly->n;i++) {
+            tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        }
+        tmp-= (myPoly->coeff[0]/2.0);
+        return(tmp);
+    */
 }
 
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 1906)
+++ /trunk/psLib/src/math/psStats.c	(revision 1907)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:37:48 $
+ *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -858,4 +858,35 @@
     for (i = 0; i < myData->n; i++) {
         myData->data.F32[i] = (myData->data.F32[i] - min) / range;
+    }
+}
+
+/*****************************************************************************
+p_psNormalizeVectorF64(myData): this is a private function which normalizes the
+elements of a vector to a range between -1.0 and 1.0.
+ 
+XXX: incorporate this into above
+ 
+XXX: 0-1 or -1:1?
+ *****************************************************************************/
+void p_psNormalizeVectorF64(psVector* myData)
+{
+    float min = (float)HUGE;
+    float max = (float)-HUGE;
+    float range = 0.0;
+    int i = 0;
+
+    for (i = 0; i < myData->n; i++) {
+        if (myData->data.F64[i] < min) {
+            min = myData->data.F64[i];
+        }
+        if (myData->data.F64[i] > max) {
+            max = myData->data.F64[i];
+        }
+    }
+
+    range = max - min;
+    for (i = 0; i < myData->n; i++) {
+        myData->data.F64[i] = -1.0 + 2.0 *
+                              ((myData->data.F64[i] - min) / range);
     }
 }
Index: /trunk/psLib/src/math/psStats.h
===================================================================
--- /trunk/psLib/src/math/psStats.h	(revision 1906)
+++ /trunk/psLib/src/math/psStats.h	(revision 1907)
@@ -10,6 +10,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-25 19:11:01 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 23:41:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -174,4 +174,9 @@
 );
 
+
+void p_psNormalizeVector(psVector* myData);
+void p_psNormalizeVectorF64(psVector* myData);
+
+
 /// @}
 
Index: /trunk/psLib/test/dataManip/Makefile
===================================================================
--- /trunk/psLib/test/dataManip/Makefile	(revision 1906)
+++ /trunk/psLib/test/dataManip/Makefile	(revision 1907)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/sysUtils
 ##
-##  $Revision: 1.45 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-09-25 20:17:43 $
+##  $Revision: 1.46 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-09-27 23:41:42 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -42,4 +42,5 @@
 tst_psMatrixVectorArithmetic03 \
 tst_psMinimize04 \
+tst_psMinimize04b \
 tst_psMinimize05 \
 tst_psMinimize06 \
Index: /trunk/psLib/test/dataManip/tst_psMinimize04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize04.c	(revision 1906)
+++ /trunk/psLib/test/dataManip/tst_psMinimize04.c	(revision 1907)
@@ -12,5 +12,5 @@
 #include <math.h>
 #define NUM_DATA 10
-#define POLY_ORDER 2
+#define POLY_ORDER 5
 
 double setData(double A,
@@ -40,5 +40,5 @@
     for (i=0;i<NUM_DATA;i++) {
         x->data.F64[i] = (double) i;
-        y->data.F64[i] = setData(2.0, 3.0, 2.0, x->data.F64[i]);
+        y->data.F64[i] = setData(3.0, 2.0, 3.0, x->data.F64[i]);
         yErr->data.F64[i] = 0.1;
         printf("Original data %d: (%.1f %.1f)\n", i, x->data.F64[i], y->data.F64[i]);
