Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 5093)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 5094)
@@ -7,6 +7,6 @@
 *  polynomials.  It also contains a Gaussian functions.
 *
-*  @version $Revision: 1.125 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-22 20:45:43 $
+*  @version $Revision: 1.126 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-22 22:22:15 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -161,7 +161,11 @@
 used frequently and the data structure created here does not contain the
 outer coefficients of the Chebyshev polynomials.
+ 
+XXX: From the poly nOrder/nTerm changem the maxChebyPoly here is still nTerms,
+not nOrder.
  *****************************************************************************/
-static psPolynomial1D **createChebyshevPolys(unsigned int maxChebyPoly)
-{
+static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
+{
+    //printf("createChebyshevPolys(%d)\n", maxChebyPoly);
     PS_ASSERT_INT_NONNEGATIVE(maxChebyPoly, NULL);
 
@@ -169,6 +173,6 @@
 
     chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
-    for (unsigned int i = 0; i < maxChebyPoly; i++) {
-        chebPolys[i] = psPolynomial1DAlloc(i, PS_POLYNOMIAL_ORD);
+    for (psS32 i = 0; i < maxChebyPoly; i++) {
+        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
     }
 
@@ -184,7 +188,9 @@
             for (psS32 j = 0; j < chebPolys[i - 1]->COOL_1D_n; j++) {
                 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
+                //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j + 1, chebPolys[i]->coeff[j + 1]);
             }
             for (psS32 j = 0; j < chebPolys[i - 2]->COOL_1D_n; j++) {
                 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
+                //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j, chebPolys[i]->coeff[j]);
             }
         }
@@ -203,4 +209,8 @@
                                  const psPolynomial1D* poly)
 {
+    //printf("ordPolynomial1DEval(%f): ", x);
+    //for (psS32 i = 0 ; i < (1 + poly->COOL_1D_n) ; i++) printf("(%.2f) ", poly->coeff[i]);
+    //printf("\n");
+
     unsigned int loop_x = 0;
     psF64 polySum = 0.0;
@@ -527,4 +537,5 @@
         maxChebyPoly = poly->COOL_4D_nT;
     }
+    // XXX: Add 1 since createChebyshevPolys() takes nTerms, not nOrder.
     chebPolys = createChebyshevPolys(maxChebyPoly + 1);
 
@@ -532,9 +543,9 @@
         for (loop_y = 0; loop_y < (1 + poly->COOL_4D_nY); loop_y++) {
             for (loop_z = 0; loop_z < (1 + poly->COOL_4D_nZ); loop_z++) {
-                for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nZ); loop_t++) {
+                for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nT); loop_t++) {
                     if (poly->mask[loop_x][loop_y][loop_z][loop_t] == 0) {
                         //printf("HMMM (%d, %d, %d, %d)\n", loop_x, loop_y, loop_z, loop_t);
                         //printf("HMMM (%d, %d, %d, %d)\n", chebPolys[loop_x]->COOL_1D_n, chebPolys[loop_y]->COOL_1D_n, chebPolys[loop_z]->COOL_1D_n, chebPolys[loop_t]->COOL_1D_n);
-
+                        //printf("chebPolynomial4DEval()\n");
                         polySum += poly->coeff[loop_x][loop_y][loop_z][loop_t] *
                                    psPolynomial1DEval(chebPolys[loop_x], x) *
Index: /trunk/psLib/test/math/tst_psFunc10.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc10.c	(revision 5093)
+++ /trunk/psLib/test/math/tst_psFunc10.c	(revision 5094)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.5 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-09-22 20:45:43 $
+*  @version  $Revision: 1.6 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-09-22 22:22:15 $
 *
 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -184,5 +184,5 @@
     psFree(polyOrd);
 
-    return 0;
+    return(testStatus);
 }
 
@@ -320,5 +320,5 @@
     psFree(polyCheb);
 
-    return 0;
+    return(testStatus);
 }
 
Index: /trunk/psLib/test/math/tst_psFunc11.c
===================================================================
--- /trunk/psLib/test/math/tst_psFunc11.c	(revision 5093)
+++ /trunk/psLib/test/math/tst_psFunc11.c	(revision 5094)
@@ -4,6 +4,6 @@
 *  ORD and CHEB type polynomials.
 *
-*  @version  $Revision: 1.5 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-09-22 20:45:43 $
+*  @version  $Revision: 1.6 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-09-22 22:22:15 $
 *
 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -19,9 +19,9 @@
 
 static psS32 testPoly4DEval(void);
-//static psS32 testPoly4DEvalVector(void);
+static psS32 testPoly4DEvalVector(void);
 
 testDescription tests[] = {
                               {testPoly4DEval,583,"psPolynomial4DEval",true,false},
-                              //                              {testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false},
+                              {testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false},
                               {NULL}
                           };
@@ -378,5 +378,4 @@
 {
     psBool testStatus = true;
-
     // Allocate polynomial structure
     psPolynomial4D*  polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD);
@@ -405,5 +404,4 @@
             testStatus = false;
         }
-
         psF64 resultCheb = psPolynomial4DEval(polyCheb,Dpoly4DWXYZChebValue[i][0],Dpoly4DWXYZChebValue[i][1],
                                               Dpoly4DWXYZChebValue[i][2],Dpoly4DWXYZChebValue[i][3]);
@@ -431,11 +429,12 @@
     return(testStatus);
 }
-/*
+
 psS32 testPoly4DEvalVector(void)
 {
+    psBool testStatus = true;
     // Allocate polynomial
     psPolynomial4D* polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD);
     psPolynomial4D* polyCheb = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_CHEB);
- 
+
     // Set polynomial members
     for(psS32 i = 0; i < TERMS; i++) {
@@ -451,5 +450,5 @@
         }
     }
- 
+
     // Create input vectors
     psVector* inputOrdW  = psVectorAlloc(TESTPOINTS, PS_TYPE_F64);
@@ -471,5 +470,5 @@
         inputChebZ->data.F64[i] = Dpoly4DWXYZChebValue[i][3];
     }
- 
+
     // Evaluate the vectors
     psVector* outputOrd = psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ);
@@ -480,5 +479,5 @@
     if(outputOrd->type.type != PS_TYPE_F64) {
         printf("TEST ERROR: Output vector of type %d expected %d",
-                outputOrd->type.type, PS_TYPE_F64);
+               outputOrd->type.type, PS_TYPE_F64);
         testStatus = false;
     }
@@ -490,22 +489,22 @@
     if(outputCheb->type.type != PS_TYPE_F64) {
         printf("TEST ERROR: Output vector of type %d expected %d",
-                outputCheb->type.type, PS_TYPE_F64);
-        testStatus = false;
-    }
- 
+               outputCheb->type.type, PS_TYPE_F64);
+        testStatus = false;
+    }
+
     // Verify the results
     for(psS32 i = 0; i < TESTPOINTS; i++) {
         if(fabs(Dpoly4DResult[i]-outputOrd->data.F64[i]) > ERROR_TOL) {
             printf("TEST ERROR: Result[%d] %lg not equal to expected %lg",
-                    i, outputOrd->data.F64[i], Dpoly4DResult[i]);
+                   i, outputOrd->data.F64[i], Dpoly4DResult[i]);
             testStatus = false;
         }
         if(fabs(Dpoly4DChebResult[i]-outputCheb->data.F64[i]) > ERROR_TOL) {
             printf("TEST ERROR: ResultCheb[%d] %lg not equal to expected %lg",
-                    i, outputCheb->data.F64[i], Dpoly4DChebResult[i]);
+                   i, outputCheb->data.F64[i], Dpoly4DChebResult[i]);
             testStatus = false;
         }
     }
- 
+
     // Attempt to invoke function with null polynomial
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL polynomial");
@@ -514,5 +513,5 @@
         testStatus = false;
     }
- 
+
     // Attempt to invoke function with null input vector
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL input vector");
@@ -539,5 +538,5 @@
         testStatus = false;
     }
- 
+
     // Attempt to invoke function with a non F64 type input vector
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid input type");
@@ -572,5 +571,5 @@
     }
     inputOrdW->type.type = PS_TYPE_F64;
- 
+
     psFree(inputOrdX);
     psFree(inputOrdY);
@@ -585,7 +584,5 @@
     psFree(polyOrd);
     psFree(polyCheb);
- 
+
     return(testStatus);
 }
- 
-*/
