Changeset 11374
- Timestamp:
- Jan 29, 2007, 11:32:50 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tap_psPolynomialEval1D.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psPolynomialEval1D.c
r10740 r11374 1 /** tst_psFunc08.c1 /** 2 2 * 3 3 * This test driver will exercise the psPolynomialXDEval functions for both 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $7 * @date $Date: 200 6-12-15 00:41:49$6 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-01-29 21:32:50 $ 8 8 * 9 9 * XXX: Probably should test single- and multi-dimensional polynomials in … … 25 25 #define TESTPOINTS 5 26 26 #define ERROR_TOL 0.001 27 #define VERBOSE 028 27 29 28 psF32 poly1DCoeff[TERMS] = { -4.3, 2.3, -3.2, 1.9}; … … 45 44 psLogSetFormat("HLNM"); 46 45 psLogSetLevel(PS_LOG_INFO); 47 48 46 plan_tests(24); 49 diag("psPolynomial1DEval() tests");50 47 51 48 // Allocate and evaluate an ordinary polynomial structure … … 54 51 55 52 // Allocate polynomial structure 56 diag("Allocate a 1D polynomial with psPolynomial1DAlloc()");57 53 psPolynomial1D* polyOrd = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, TERMS-1); 58 54 ok(polyOrd != NULL, "Ordinary psPolynomial1D successfully allocated"); … … 67 63 68 64 // Evaluate test points and verify results 69 psBool errorFlag = false;65 bool errorFlag = false; 70 66 for(psS32 i = 0; i < TESTPOINTS; i++) 71 67 { 72 68 psF64 result = psPolynomial1DEval(polyOrd,poly1DXValue[i]); 73 if(fabs(poly1DXResult[i]-result) > ERROR_TOL ) { 74 if (VERBOSE) { 75 psError(PS_ERR_UNKNOWN,true,"Evaluated value %g not as expected %g", 76 result, poly1DXResult[i]); 77 } 69 if (fabs(poly1DXResult[i]-result) > ERROR_TOL ) { 70 diag("Evaluated value %g not as expected %g", result, poly1DXResult[i]); 78 71 errorFlag = true; 79 72 } … … 88 81 // Allocate Cheby polynomial structure 89 82 { 90 psBool errorFlag = false; 91 psMemId id = psMemGetId(); 92 diag("Allocate a 1D polynomial with psPolynomial1DAlloc()"); 83 bool errorFlag = false; 84 psMemId id = psMemGetId(); 93 85 psPolynomial1D* polyCheb = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, TERMS-1); 94 86 ok(polyCheb != NULL, "Chebyshev psPolynomial1D successfully allocated"); … … 105 97 { 106 98 psF64 resultCheb = psPolynomial1DEval(polyCheb,poly1DXChebValue[i]); 107 if(fabs(poly1DXChebResult[i]-resultCheb) > ERROR_TOL ) { 108 if (VERBOSE) { 109 psError(PS_ERR_UNKNOWN,true,"Evaluated value %g not as expected %g", 110 resultCheb, poly1DXChebResult[i]); 111 } 99 if (fabs(poly1DXChebResult[i]-resultCheb) > ERROR_TOL ) { 100 diag("Evaluated value %g not as expected %g", resultCheb, poly1DXChebResult[i]); 112 101 errorFlag = true; 113 102 } … … 121 110 // Allocate polynomial with unallowable type 122 111 { 123 diag("Allocate a 1D polynomial with an unallowed type");124 112 psMemId id = psMemGetId(); 125 113 psPolynomial1D* polyOrd = psPolynomial1DAlloc(99, TERMS-1); … … 127 115 skip_start(polyOrd!=NULL, 1, "Skipping tests because psPolynomial1DAlloc() failed"); 128 116 129 diag("Attempt to evaluate an 1D polynomial with an unallowed type");130 117 // Attempt to evaluation invalid polynomial type 131 118 psF64 result = psPolynomial1DEval(polyOrd, 0.0); … … 139 126 // Allocate polynomial, test the psPolynomial1DEvalVector() routines 140 127 { 141 diag("Test psPolynomial1DEvalVector(), ordinary polynomials");142 128 psMemId id = psMemGetId(); 143 129 psPolynomial1D* polyOrd = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, TERMS-1); … … 166 152 167 153 // Verify the results 168 psBool errorFlag = false; 169 for(psS32 i = 0; i < TESTPOINTS; i++) 170 { 171 if(fabs(poly1DXResult[i]-outputOrd->data.F64[i]) > ERROR_TOL) { 172 if (VERBOSE) { 173 psError(PS_ERR_UNKNOWN,true,"Result[%d] %lg not equal to expected %lg", 174 i, outputOrd->data.F64[i], poly1DXResult[i]); 175 } 154 bool errorFlag = false; 155 for(psS32 i = 0; i < TESTPOINTS; i++) 156 { 157 if (fabs(poly1DXResult[i]-outputOrd->data.F64[i]) > ERROR_TOL) { 158 diag("Result[%d] %lg not equal to expected %lg", 159 i, outputOrd->data.F64[i], poly1DXResult[i]); 176 160 errorFlag = TRUE; 177 161 } … … 199 183 // Allocate polynomial, test the psPolynomial1DEvalVector() routines (Chebyshev) 200 184 { 201 diag("Test psPolynomial1DEvalVector(), Cheby polynomials");202 185 psMemId id = psMemGetId(); 203 186 psPolynomial1D* polyCheb = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, TERMS-1); … … 226 209 227 210 // Verify the results 228 psBool errorFlag = false; 229 for(psS32 i = 0; i < TESTPOINTS; i++) 230 { 231 if(fabs(poly1DXChebResult[i]-outputCheb->data.F64[i]) > ERROR_TOL) { 232 if (VERBOSE) { 233 psError(PS_ERR_UNKNOWN,true,"ResultCheb[%d] %lg not equal to expected %lg", 234 i, outputCheb->data.F64[i], poly1DXChebResult[i]); 235 } 211 bool errorFlag = false; 212 for(psS32 i = 0; i < TESTPOINTS; i++) 213 { 214 if (fabs(poly1DXChebResult[i]-outputCheb->data.F64[i]) > ERROR_TOL) { 215 diag("ResultCheb[%d] %lg not equal to expected %lg", 216 i, outputCheb->data.F64[i], poly1DXChebResult[i]); 236 217 errorFlag = TRUE; 237 218 }
Note:
See TracChangeset
for help on using the changeset viewer.
