- Timestamp:
- Dec 9, 2006, 6:13:25 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psPolynomialUtils_Derivatives.c
r10597 r10605 8 8 int main (void) 9 9 { 10 plan_tests( 48);10 plan_tests(72); 11 11 12 12 diag("psPolynomial2D Derivative tests"); … … 109 109 } 110 110 111 // test psPolynomial2D_dX (inPlace: supplied output == supplied input) 112 { 113 psMemId id = psMemGetId(); 114 115 diag ("test psPolynomial2D_dX (supplied output)"); 116 117 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 2, 2); 118 ok(poly != NULL, "psPolynomial2D successfully allocated"); 119 skip_start(poly == NULL, 5, "Skipping tests because psPolynomial2DAlloc() failed"); 120 121 // build sample polynomial (upper-left elements only) 122 // z = 5 + 2x + 3y - 3x^2 + 4xy - 2y^2 123 // dz/dx = 2 - 6x + 4y 124 poly->coeff[0][0] = 5.0; 125 poly->coeff[1][0] = 2.0; 126 poly->coeff[0][1] = 3.0; 127 poly->coeff[2][0] = -3.0; 128 poly->coeff[1][1] = 4.0; 129 poly->coeff[0][2] = -2.0; 130 131 // mask remaining elements 132 poly->mask[2][1] = 1; 133 poly->mask[1][2] = 1; 134 poly->mask[2][2] = 1; 135 136 poly = psPolynomial2D_dX (poly, poly); 137 138 ok(poly->nX == 1, "new x order is %d", poly->nX); 139 ok(poly->nY == 2, "new y order is %d", poly->nY); 140 141 ok_float(poly->coeff[0][0], +2.0, "x^0 y^0 coeff is %f", poly->coeff[0][0]); 142 ok_float(poly->coeff[1][0], -6.0, "x^1 y^0 coeff is %f", poly->coeff[1][0]); 143 ok_float(poly->coeff[0][1], +4.0, "x^0 y^1 coeff is %f", poly->coeff[0][1]); 144 145 ok(!poly->mask[0][0], "x^0 y^0 coeff is unmasked"); 146 ok(!poly->mask[1][0], "x^1 y^0 coeff is unmasked"); 147 ok(!poly->mask[0][1], "x^0 y^1 coeff is unmasked"); 148 149 ok(poly->mask[1][1], "x^1 y^1 coeff is masked"); 150 ok(poly->mask[1][2], "x^1 y^2 coeff is masked"); 151 152 psFree (poly); 153 154 skip_end(); 155 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 156 } 157 111 158 // test psPolynomial2D_dY (no supplied output) 112 159 { … … 136 183 psPolynomial2D *dY = psPolynomial2D_dY (NULL, poly); 137 184 138 ok(dY->nX == 1, "new x order is %d", dY->nX);139 ok(dY->nY == 2, "new y order is %d", dY->nY);185 ok(dY->nX == 2, "new x order is %d", dY->nX); 186 ok(dY->nY == 1, "new y order is %d", dY->nY); 140 187 141 188 ok_float(dY->coeff[0][0], +3.0, "x^0 y^0 coeff is %f", dY->coeff[0][0]); … … 185 232 psPolynomial2D_dY (dY, poly); 186 233 187 ok(dY->nX == 1, "new x order is %d", dY->nX);188 ok(dY->nY == 2, "new y order is %d", dY->nY);234 ok(dY->nX == 2, "new x order is %d", dY->nX); 235 ok(dY->nY == 1, "new y order is %d", dY->nY); 189 236 190 237 ok_float(dY->coeff[0][0], +3.0, "x^0 y^0 coeff is %f", dY->coeff[0][0]); … … 206 253 } 207 254 255 // test psPolynomial2D_dY (supplied output) 256 { 257 psMemId id = psMemGetId(); 258 259 diag ("test psPolynomial2D_dY (supplied output)"); 260 261 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 2, 2); 262 ok(poly != NULL, "psPolynomial2D successfully allocated"); 263 skip_start(poly == NULL, 5, "Skipping tests because psPolynomial2DAlloc() failed"); 264 265 // build sample polynomial (upper-left elements only) 266 // z = 5 + 2x + 3y - 3x^2 + 4xy - 2y^2 267 // dz/dy = 3 + 4x - 4y 268 poly->coeff[0][0] = 5.0; 269 poly->coeff[1][0] = 2.0; 270 poly->coeff[0][1] = 3.0; 271 poly->coeff[2][0] = -3.0; 272 poly->coeff[1][1] = 4.0; 273 poly->coeff[0][2] = -2.0; 274 275 // mask remaining elements 276 poly->mask[2][1] = 1; 277 poly->mask[1][2] = 1; 278 poly->mask[2][2] = 1; 279 280 poly = psPolynomial2D_dY (poly, poly); 281 282 ok(poly->nX == 2, "new x order is %d", poly->nX); 283 ok(poly->nY == 1, "new y order is %d", poly->nY); 284 285 ok_float(poly->coeff[0][0], +3.0, "x^0 y^0 coeff is %f", poly->coeff[0][0]); 286 ok_float(poly->coeff[1][0], +4.0, "x^1 y^0 coeff is %f", poly->coeff[1][0]); 287 ok_float(poly->coeff[0][1], -4.0, "x^0 y^1 coeff is %f", poly->coeff[0][1]); 288 289 ok(!poly->mask[0][0], "x^0 y^0 coeff is unmasked"); 290 ok(!poly->mask[1][0], "x^1 y^0 coeff is unmasked"); 291 ok(!poly->mask[0][1], "x^0 y^1 coeff is unmasked"); 292 293 ok(poly->mask[1][1], "x^1 y^1 coeff is masked"); 294 ok(poly->mask[1][2], "x^1 y^2 coeff is masked"); 295 296 psFree (poly); 297 298 skip_end(); 299 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 300 } 301 208 302 return exit_status(); 209 303 }
Note:
See TracChangeset
for help on using the changeset viewer.
