Index: /branches/eam_branches/ipp-20100621/psLib/test/math/tap_psPolynomialMD_sampleDark.c
===================================================================
--- /branches/eam_branches/ipp-20100621/psLib/test/math/tap_psPolynomialMD_sampleDark.c	(revision 28945)
+++ /branches/eam_branches/ipp-20100621/psLib/test/math/tap_psPolynomialMD_sampleDark.c	(revision 28946)
@@ -4,9 +4,9 @@
 #include "pstap.h"
 
-#define TOL 1.0e-8
+#define TOL 1.0e-4
 
 int main(int argc, char *argv[])
 {
-    plan_tests(2);
+    plan_tests(13);
     {
         psMemId id = psMemGetId();
@@ -16,10 +16,10 @@
 	skip_start (!f, 10, "skipping tests using polyMD.dat");
 
-	psVector *exptime = psVectorAlloc (100, PS_TYPE_F32);
-	psVector *temp    = psVectorAlloc (100, PS_TYPE_F32);
-	psVector *ord1    = psVectorAlloc (100, PS_TYPE_F32);
-	psVector *ord2    = psVectorAlloc (100, PS_TYPE_F32);
-	psVector *ord3    = psVectorAlloc (100, PS_TYPE_F32);
-	psVector *flux    = psVectorAlloc (100, PS_TYPE_F32);
+	psVector *exptime = psVectorAllocEmpty (100, PS_TYPE_F32);
+	psVector *temp    = psVectorAllocEmpty (100, PS_TYPE_F32);
+	psVector *ord1    = psVectorAllocEmpty (100, PS_TYPE_F32);
+	psVector *ord2    = psVectorAllocEmpty (100, PS_TYPE_F32);
+	psVector *ord3    = psVectorAllocEmpty (100, PS_TYPE_F32);
+	psVector *flux    = psVectorAllocEmpty (100, PS_TYPE_F32);
 
 	float Exptime, Temp, Ord1, Ord2, Ord3, Flux;
@@ -37,5 +37,5 @@
 	    psAssert (i < exptime->nalloc, "error reading data");
 	}
-	ok (exptime->n == 100, "read data");
+	ok (exptime->n == 5000, "read %d elements", exptime->n);
 
 	// fit f to ord1, ord2, ord3 (1st order only)
@@ -78,22 +78,27 @@
 
 	// fit f to exptime (1st order) and temp (2nd order)
+	// f = D0 + D1*exptime + D2*exptime*temp + D3*exptime*temp^2
         {
             psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 2);
-
+	    poly->coeffMask[0][1] = 1; // x^0 y^1
+	    poly->coeffMask[0][2] = 1; // x^0 y^2
+	    
 	    bool polyOK = psVectorFitPolynomial2D(poly, NULL, 0, flux, NULL, exptime, temp);
             ok(polyOK, "Fit polynomial");
 
             skip_start(!polyOK, 4, "Skipping coefficient checks since fit failed.");
-            // is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d", index);
-	    // is_double_tol(poly->coeff[1][0], 5.0,    TOL, "Coefficient %d", index);
-	    // is_double_tol(poly->coeff[0][1], 0.025,  TOL, "Coefficient %d", index);
-	    for (int ix = 0; ix < 2; ix++) {
-		for (int iy = 0; iy < 3; iy++) {
-		    fprintf (stderr, "poly %d %d : %f\n", ix, iy, poly->coeff[ix][iy]);
-		}
-	    }
+            is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d %d", 0, 0);
+	    is_double_tol(poly->coeff[1][0], 5.0,    TOL, "Coefficient %d %d", 1, 0);
+	    is_double_tol(poly->coeff[1][1], 0.025,  TOL, "Coefficient %d %d", 1, 1);
+	    is_double_tol(poly->coeff[1][2], 0.005,  TOL, "Coefficient %d %d", 1, 2);
             skip_end();
             psFree(poly);
         }
+	psFree(exptime);
+	psFree(temp);
+	psFree(ord1);
+	psFree(ord2);
+	psFree(ord3);
+	psFree(flux);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
 	skip_end();
