Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2260)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2261)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-28 23:03:11 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-02 01:52:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -225,5 +225,9 @@
 } \
 
-
+#define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
+if (NAME->type != TYPE) { \
+    psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \
+    return(RVAL); \
+} \
 
 /*****************************************************************************
Index: /trunk/psLib/src/image/psImageStats.c
===================================================================
--- /trunk/psLib/src/image/psImageStats.c	(revision 2260)
+++ /trunk/psLib/src/image/psImageStats.c	(revision 2261)
@@ -9,6 +9,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 20:07:17 $
+*  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-02 01:52:43 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -149,17 +149,29 @@
 }
 
+double *CalcScaleFactors(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
+
+    for (i = 0; i < n; i++) {
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
+        scalingFactors[i] = cos(tmp);
+    }
+
+    return (scalingFactors);
+}
+
 // XXX: Why do we have this function?
-float *p_psCalcScaleFactorsFit(psS32 n)
-{
-    psS32 i = 0;
-    float tmp = 0.0;
-    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+double *CalcScaleFactorsFit(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
 
     for (i = 0; i < n; i++) {
-        // ((2.0 * (float) i) / ((float) (n-1)))
-        // - 1.0;
-        // tmp = (float) (i + 1);
-        tmp = (float)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
     }
@@ -169,5 +181,5 @@
 
 /*****************************************************************************
-p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
+CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
 order to use Chebyshev polynomials, we must scale the coordinates from
@@ -175,19 +187,16 @@
 output a vector of evenly spaced floating point values between -1.0:1.0.
  *****************************************************************************/
-float *p_psCalcScaleFactorsEval(psS32 n)
-{
-    psS32 i = 0;
-    float tmp = 0.0;
-
-    return p_psCalcScaleFactorsFit(n);
-
-    printf("Should not get here\n");
-    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+double *CalcScaleFactorsEval(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+
+    return(CalcScaleFactorsFit(n));
+
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
 
     for (i = 0; i < n; i++) {
-        // scalingFactors[i] = ((2.0 * (float) i)
-        // / ((float) (n-1))) - 1.0;
-        tmp = (float)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
     }
@@ -249,9 +258,9 @@
     psS32 i = 0;
     psS32 j = 0;
-    float **sums = NULL;
+    double **sums = NULL;
     psPolynomial1D* *chebPolys = NULL;
     psS32 maxChebyPoly = 0;
-    float *cScalingFactors = NULL;
-    float *rScalingFactors = NULL;
+    double *cScalingFactors = NULL;
+    double *rScalingFactors = NULL;
 
     // Check for null inputs
@@ -275,12 +284,12 @@
     // 29 in the ADD: sums[k][l] = SUM {
     // image(x,y) * Tk(x) * Tl(y) }
-    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
+    sums = (double **)psAlloc(coeffs->nX * sizeof(double *));
     for (i = 0; i < coeffs->nX; i++) {
-        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
+        sums[i] = (double *)psAlloc(coeffs->nY * sizeof(double));
     }
     // We scale the pixel positions to values
     // between -1.0 and 1.0
-    rScalingFactors = p_psCalcScaleFactorsFit(input->numRows);
-    cScalingFactors = p_psCalcScaleFactorsFit(input->numCols);
+    rScalingFactors = CalcScaleFactors(input->numRows);
+    cScalingFactors = CalcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
@@ -292,21 +301,4 @@
     chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
 
-
-    /*
-        // Sanity check for the Chebyshevs.
-        for (i = 0; i < coeffs->nX; i++) {
-            for (j = 0; j < coeffs->nY; j++) {
-                tmp = 0.0;
-                for (x = 0; x < input->numRows; x++) {
-                    tmp +=
-                        psPolynomial1DEval
-                        (rScalingFactors[x], chebPolys[i]) * psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);
-     
-                }
-                // printf("SUM(Cheby(%d) * Cheby(%d))
-                // is %f\n", i, j, tmp);
-            }
-        }
-    */
 
     // Compute the sums[][] data structure.
@@ -362,7 +354,19 @@
  
 XXX: Currently we only support F32.
+     S8, U16, F32, F64
  *****************************************************************************/
 psImage* psImageEvalPolynomial(psImage* input, const psPolynomial2D* coeffs)
 {
+    PS_IMAGE_CHECK_NULL(input, NULL);
+    PS_IMAGE_CHECK_EMPTY(input, NULL);
+    if ((input->type.type != PS_TYPE_S8) &&
+            (input->type.type != PS_TYPE_U16) &&
+            (input->type.type != PS_TYPE_F32) &&
+            (input->type.type != PS_TYPE_F64)) {
+        psError(__func__, "Unalowwable image type.\n");
+    }
+    PS_POLY_CHECK_NULL(coeffs, NULL);
+    PS_POLY_CHECK_TYPE(coeffs, PS_POLYNOMIAL_CHEB, NULL);
+
     psS32 x = 0;
     psS32 y = 0;
@@ -372,42 +376,13 @@
     psPolynomial1D* *chebPolys = NULL;
     psS32 maxChebyPoly = 0;
-    float *cScalingFactors = NULL;
-    float *rScalingFactors = NULL;
-    float polySum = 0.0;
-
-    // Create the sums[][] data structure.  This will hold the LHS of
-    // equation 29 in the ADD:
-    //         sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) }
-    //
-    //    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
-    //    for (i = 0; i < coeffs->nX; i++) {
-    //        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
-    //    }
-    //    for (i = 0; i < coeffs->nX; i++) {
-    //        for (j = 0; j < coeffs->nY; j++) {
-    //            sums[i][j] = 0.0;
-    //        }
-    //    }
-
-
-    // Check for null inputs
-    if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
-        return NULL;
-    }
-
-    if (coeffs == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_COEFF_NULL);
-        return NULL;
-    }
+    double *cScalingFactors = NULL;
+    double *rScalingFactors = NULL;
+    double polySum = 0.0;
+
 
     // We scale the pixel positions to values between -1.0 and 1.0
     // Use static data structures here.
-    rScalingFactors = p_psCalcScaleFactorsEval(input->numRows);
-    cScalingFactors = p_psCalcScaleFactorsEval(input->numCols);
+    rScalingFactors = CalcScaleFactors(input->numRows);
+    cScalingFactors = CalcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 2260)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 2261)
@@ -9,6 +9,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 20:07:17 $
+*  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-02 01:52:43 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -149,17 +149,29 @@
 }
 
+double *CalcScaleFactors(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
+
+    for (i = 0; i < n; i++) {
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
+        scalingFactors[i] = cos(tmp);
+    }
+
+    return (scalingFactors);
+}
+
 // XXX: Why do we have this function?
-float *p_psCalcScaleFactorsFit(psS32 n)
-{
-    psS32 i = 0;
-    float tmp = 0.0;
-    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+double *CalcScaleFactorsFit(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
 
     for (i = 0; i < n; i++) {
-        // ((2.0 * (float) i) / ((float) (n-1)))
-        // - 1.0;
-        // tmp = (float) (i + 1);
-        tmp = (float)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
     }
@@ -169,5 +181,5 @@
 
 /*****************************************************************************
-p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
+CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
 order to use Chebyshev polynomials, we must scale the coordinates from
@@ -175,19 +187,16 @@
 output a vector of evenly spaced floating point values between -1.0:1.0.
  *****************************************************************************/
-float *p_psCalcScaleFactorsEval(psS32 n)
-{
-    psS32 i = 0;
-    float tmp = 0.0;
-
-    return p_psCalcScaleFactorsFit(n);
-
-    printf("Should not get here\n");
-    float *scalingFactors = (float *)psAlloc(n * sizeof(float));
+double *CalcScaleFactorsEval(psS32 n)
+{
+    psS32 i = 0;
+    double tmp = 0.0;
+
+    return(CalcScaleFactorsFit(n));
+
+    double *scalingFactors = (double *)psAlloc(n * sizeof(double));
 
     for (i = 0; i < n; i++) {
-        // scalingFactors[i] = ((2.0 * (float) i)
-        // / ((float) (n-1))) - 1.0;
-        tmp = (float)(n - i);
-        tmp = (M_PI * (tmp - 0.5)) / ((float)n);
+        tmp = (double)(n - i);
+        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
         scalingFactors[i] = cos(tmp);
     }
@@ -249,9 +258,9 @@
     psS32 i = 0;
     psS32 j = 0;
-    float **sums = NULL;
+    double **sums = NULL;
     psPolynomial1D* *chebPolys = NULL;
     psS32 maxChebyPoly = 0;
-    float *cScalingFactors = NULL;
-    float *rScalingFactors = NULL;
+    double *cScalingFactors = NULL;
+    double *rScalingFactors = NULL;
 
     // Check for null inputs
@@ -275,12 +284,12 @@
     // 29 in the ADD: sums[k][l] = SUM {
     // image(x,y) * Tk(x) * Tl(y) }
-    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
+    sums = (double **)psAlloc(coeffs->nX * sizeof(double *));
     for (i = 0; i < coeffs->nX; i++) {
-        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
+        sums[i] = (double *)psAlloc(coeffs->nY * sizeof(double));
     }
     // We scale the pixel positions to values
     // between -1.0 and 1.0
-    rScalingFactors = p_psCalcScaleFactorsFit(input->numRows);
-    cScalingFactors = p_psCalcScaleFactorsFit(input->numCols);
+    rScalingFactors = CalcScaleFactors(input->numRows);
+    cScalingFactors = CalcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
@@ -292,21 +301,4 @@
     chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
 
-
-    /*
-        // Sanity check for the Chebyshevs.
-        for (i = 0; i < coeffs->nX; i++) {
-            for (j = 0; j < coeffs->nY; j++) {
-                tmp = 0.0;
-                for (x = 0; x < input->numRows; x++) {
-                    tmp +=
-                        psPolynomial1DEval
-                        (rScalingFactors[x], chebPolys[i]) * psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);
-     
-                }
-                // printf("SUM(Cheby(%d) * Cheby(%d))
-                // is %f\n", i, j, tmp);
-            }
-        }
-    */
 
     // Compute the sums[][] data structure.
@@ -362,7 +354,19 @@
  
 XXX: Currently we only support F32.
+     S8, U16, F32, F64
  *****************************************************************************/
 psImage* psImageEvalPolynomial(psImage* input, const psPolynomial2D* coeffs)
 {
+    PS_IMAGE_CHECK_NULL(input, NULL);
+    PS_IMAGE_CHECK_EMPTY(input, NULL);
+    if ((input->type.type != PS_TYPE_S8) &&
+            (input->type.type != PS_TYPE_U16) &&
+            (input->type.type != PS_TYPE_F32) &&
+            (input->type.type != PS_TYPE_F64)) {
+        psError(__func__, "Unalowwable image type.\n");
+    }
+    PS_POLY_CHECK_NULL(coeffs, NULL);
+    PS_POLY_CHECK_TYPE(coeffs, PS_POLYNOMIAL_CHEB, NULL);
+
     psS32 x = 0;
     psS32 y = 0;
@@ -372,42 +376,13 @@
     psPolynomial1D* *chebPolys = NULL;
     psS32 maxChebyPoly = 0;
-    float *cScalingFactors = NULL;
-    float *rScalingFactors = NULL;
-    float polySum = 0.0;
-
-    // Create the sums[][] data structure.  This will hold the LHS of
-    // equation 29 in the ADD:
-    //         sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) }
-    //
-    //    sums = (float **)psAlloc(coeffs->nX * sizeof(float *));
-    //    for (i = 0; i < coeffs->nX; i++) {
-    //        sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float));
-    //    }
-    //    for (i = 0; i < coeffs->nX; i++) {
-    //        for (j = 0; j < coeffs->nY; j++) {
-    //            sums[i][j] = 0.0;
-    //        }
-    //    }
-
-
-    // Check for null inputs
-    if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
-        return NULL;
-    }
-
-    if (coeffs == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_COEFF_NULL);
-        return NULL;
-    }
+    double *cScalingFactors = NULL;
+    double *rScalingFactors = NULL;
+    double polySum = 0.0;
+
 
     // We scale the pixel positions to values between -1.0 and 1.0
     // Use static data structures here.
-    rScalingFactors = p_psCalcScaleFactorsEval(input->numRows);
-    cScalingFactors = p_psCalcScaleFactorsEval(input->numCols);
+    rScalingFactors = CalcScaleFactors(input->numRows);
+    cScalingFactors = CalcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2260)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2261)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-28 23:03:11 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-02 01:52:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -225,5 +225,9 @@
 } \
 
-
+#define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
+if (NAME->type != TYPE) { \
+    psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \
+    return(RVAL); \
+} \
 
 /*****************************************************************************
