Changeset 28946
- Timestamp:
- Aug 17, 2010, 3:34:04 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psLib/test/math/tap_psPolynomialMD_sampleDark.c
r28919 r28946 4 4 #include "pstap.h" 5 5 6 #define TOL 1.0e- 86 #define TOL 1.0e-4 7 7 8 8 int main(int argc, char *argv[]) 9 9 { 10 plan_tests( 2);10 plan_tests(13); 11 11 { 12 12 psMemId id = psMemGetId(); … … 16 16 skip_start (!f, 10, "skipping tests using polyMD.dat"); 17 17 18 psVector *exptime = psVectorAlloc (100, PS_TYPE_F32);19 psVector *temp = psVectorAlloc (100, PS_TYPE_F32);20 psVector *ord1 = psVectorAlloc (100, PS_TYPE_F32);21 psVector *ord2 = psVectorAlloc (100, PS_TYPE_F32);22 psVector *ord3 = psVectorAlloc (100, PS_TYPE_F32);23 psVector *flux = psVectorAlloc (100, PS_TYPE_F32);18 psVector *exptime = psVectorAllocEmpty (100, PS_TYPE_F32); 19 psVector *temp = psVectorAllocEmpty (100, PS_TYPE_F32); 20 psVector *ord1 = psVectorAllocEmpty (100, PS_TYPE_F32); 21 psVector *ord2 = psVectorAllocEmpty (100, PS_TYPE_F32); 22 psVector *ord3 = psVectorAllocEmpty (100, PS_TYPE_F32); 23 psVector *flux = psVectorAllocEmpty (100, PS_TYPE_F32); 24 24 25 25 float Exptime, Temp, Ord1, Ord2, Ord3, Flux; … … 37 37 psAssert (i < exptime->nalloc, "error reading data"); 38 38 } 39 ok (exptime->n == 100, "read data");39 ok (exptime->n == 5000, "read %d elements", exptime->n); 40 40 41 41 // fit f to ord1, ord2, ord3 (1st order only) … … 78 78 79 79 // fit f to exptime (1st order) and temp (2nd order) 80 // f = D0 + D1*exptime + D2*exptime*temp + D3*exptime*temp^2 80 81 { 81 82 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 2); 82 83 poly->coeffMask[0][1] = 1; // x^0 y^1 84 poly->coeffMask[0][2] = 1; // x^0 y^2 85 83 86 bool polyOK = psVectorFitPolynomial2D(poly, NULL, 0, flux, NULL, exptime, temp); 84 87 ok(polyOK, "Fit polynomial"); 85 88 86 89 skip_start(!polyOK, 4, "Skipping coefficient checks since fit failed."); 87 // is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d", index); 88 // is_double_tol(poly->coeff[1][0], 5.0, TOL, "Coefficient %d", index); 89 // is_double_tol(poly->coeff[0][1], 0.025, TOL, "Coefficient %d", index); 90 for (int ix = 0; ix < 2; ix++) { 91 for (int iy = 0; iy < 3; iy++) { 92 fprintf (stderr, "poly %d %d : %f\n", ix, iy, poly->coeff[ix][iy]); 93 } 94 } 90 is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d %d", 0, 0); 91 is_double_tol(poly->coeff[1][0], 5.0, TOL, "Coefficient %d %d", 1, 0); 92 is_double_tol(poly->coeff[1][1], 0.025, TOL, "Coefficient %d %d", 1, 1); 93 is_double_tol(poly->coeff[1][2], 0.005, TOL, "Coefficient %d %d", 1, 2); 95 94 skip_end(); 96 95 psFree(poly); 97 96 } 97 psFree(exptime); 98 psFree(temp); 99 psFree(ord1); 100 psFree(ord2); 101 psFree(ord3); 102 psFree(flux); 98 103 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 99 104 skip_end();
Note:
See TracChangeset
for help on using the changeset viewer.
