Changeset 4954 for trunk/psphot/src/psPolynomials.c
- Timestamp:
- Sep 6, 2005, 5:33:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psPolynomials.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psPolynomials.c
r4901 r4954 1 1 # include "psphot.h" 2 3 // XXX EAM : this file defines alternate versions of the polynomial fitting 4 // functions. these differ from psLib v.0.5.0 in the definition 5 // of nOrder (here we use nOrder in the mathematical sense, not 6 // like IRAF. ie, a linear function is of nOrder 1) 7 // psLib v 0.7.0 should be in sync with out defintion of nOrder 8 // If so, we can drop these functions and use the psLib versions. 2 9 3 10 // write out the terms of the given 1D polynomial … … 9 16 } 10 17 11 psF 32 Polynomial1DEval_EAM(psF32x, const psPolynomial1D* myPoly)18 psF64 Polynomial1DEval_EAM(psF64 x, const psPolynomial1D* myPoly) 12 19 { 13 20 psS32 loop_x = 0; 14 psF 32polySum = 0.0;15 psF 32xSum = 1.0;21 psF64 polySum = 0.0; 22 psF64 xSum = 1.0; 16 23 17 24 for (loop_x = 0; loop_x < myPoly->n + 1; loop_x++) { … … 28 35 const psVector *x) 29 36 { 30 PS_POLY_CHECK_NULL(myPoly, NULL);31 PS_VECTOR_CHECK_NULL(x, NULL);32 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);37 // PS_POLY_CHECK_NULL(myPoly, NULL); 38 // PS_VECTOR_CHECK_NULL(x, NULL); 39 // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL); 33 40 34 41 psVector *tmp; … … 56 63 psPolynomialType type) 57 64 { 58 PS_INT_CHECK_NON_NEGATIVE(nOrder, NULL);65 // PS_INT_CHECK_NON_NEGATIVE(nOrder, NULL); 59 66 60 67 psS32 i = 0; … … 65 72 newPoly->type = type; 66 73 newPoly->n = nOrder; 67 newPoly->coeff = (psF 32 *)psAlloc(nTerm * sizeof(psF32));68 newPoly->coeffErr = (psF 32 *)psAlloc(nTerm * sizeof(psF32));74 newPoly->coeff = (psF64 *)psAlloc(nTerm * sizeof(psF64)); 75 newPoly->coeffErr = (psF64 *)psAlloc(nTerm * sizeof(psF64)); 69 76 newPoly->mask = (psU8 *)psAlloc(nTerm * sizeof(psU8)); 70 77 for (i = 0; i < nTerm; i++) { … … 73 80 newPoly->mask[i] = 0; 74 81 } 75 p _psMemSetDeallocator(newPoly, (psFreeFcn) psPolynomial1DFree);82 psMemSetDeallocator(newPoly, (psFreeFunc) psPolynomial1DFree); 76 83 return(newPoly); 77 84 } … … 120 127 // dump minutiae 121 128 # ifndef PS_NO_TRACE 129 # if (0) 130 // XXX EAM : change from FILE to fd breaks this code: 122 131 if (psTraceGetLevel (".psLib.dataManip.VectorFitPolynomial1DOrd") >= 5) { 123 132 FILE *f = psTraceGetDestination (); … … 127 136 } 128 137 } 138 # endif 129 139 # endif 130 140 … … 214 224 215 225 { 216 PS_POLY_CHECK_NULL(myPoly, NULL);217 PS_VECTOR_CHECK_NULL(x, NULL);218 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);219 PS_VECTOR_CHECK_NULL(y, NULL);220 PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F32, NULL);226 // PS_POLY_CHECK_NULL(myPoly, NULL); 227 // PS_VECTOR_CHECK_NULL(x, NULL); 228 // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL); 229 // PS_VECTOR_CHECK_NULL(y, NULL); 230 // PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F32, NULL); 221 231 222 232 psVector *tmp; … … 246 256 247 257 { 248 PS_POLY_CHECK_NULL(myPoly, NULL);249 PS_VECTOR_CHECK_NULL(x, NULL);250 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);251 PS_VECTOR_CHECK_NULL(y, NULL);252 PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F64, NULL);258 // PS_POLY_CHECK_NULL(myPoly, NULL); 259 // PS_VECTOR_CHECK_NULL(x, NULL); 260 // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL); 261 // PS_VECTOR_CHECK_NULL(y, NULL); 262 // PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F64, NULL); 253 263 254 264 psVector *tmp; … … 291 301 psPolynomialType type) 292 302 { 293 PS_INT_CHECK_NON_NEGATIVE(nXorder, NULL);294 PS_INT_CHECK_NON_NEGATIVE(nYorder, NULL);303 // PS_INT_CHECK_NON_NEGATIVE(nXorder, NULL); 304 // PS_INT_CHECK_NON_NEGATIVE(nYorder, NULL); 295 305 296 306 psS32 x = 0; … … 305 315 newPoly->nY = nYorder; 306 316 307 newPoly->coeff = (psF32 **)psAlloc(nXterm * sizeof(psF32 *)); 308 newPoly->coeffErr = (psF32 **)psAlloc(nXterm * sizeof(psF32 *)); 309 newPoly->mask = (psU8 **)psAlloc(nXterm * sizeof(psU8 *)); 317 newPoly->coeff = (psF64 **)psAlloc(nXterm * sizeof(psF64 *)); 318 newPoly->coeffErr = (psF64 **)psAlloc(nXterm * sizeof(psF64 *)); 319 newPoly->mask = (char **)psAlloc(nXterm * sizeof(char *)); 320 // XXX EAM : this is an error in the definition of the polynomial mask 321 // (should be psU8 not char) 310 322 for (x = 0; x < nXterm; x++) { 311 newPoly->coeff[x] = (psF 32 *)psAlloc(nYterm * sizeof(psF32));312 newPoly->coeffErr[x] = (psF 32 *)psAlloc(nYterm * sizeof(psF32));313 newPoly->mask[x] = ( psU8 *)psAlloc(nYterm * sizeof(psU8));323 newPoly->coeff[x] = (psF64 *)psAlloc(nYterm * sizeof(psF64)); 324 newPoly->coeffErr[x] = (psF64 *)psAlloc(nYterm * sizeof(psF64)); 325 newPoly->mask[x] = (char *)psAlloc(nYterm * sizeof(char)); 314 326 } 315 327 for (x = 0; x < nXterm; x++) { … … 320 332 } 321 333 } 322 p _psMemSetDeallocator(newPoly, (psFreeFcn) psPolynomial2DFree);334 psMemSetDeallocator(newPoly, (psFreeFunc) psPolynomial2DFree); 323 335 return(newPoly); 324 336 } … … 510 522 const psVector* dz) 511 523 { 512 PS_VECTOR_CHECK_NULL(mask, NULL);513 PS_VECTOR_CHECK_NULL(x, NULL);514 PS_VECTOR_CHECK_NULL(y, NULL);515 PS_VECTOR_CHECK_NULL(z, NULL);516 PS_VECTOR_CHECK_NULL(dz, NULL);524 // PS_VECTOR_CHECK_NULL(mask, NULL); 525 // PS_VECTOR_CHECK_NULL(x, NULL); 526 // PS_VECTOR_CHECK_NULL(y, NULL); 527 // PS_VECTOR_CHECK_NULL(z, NULL); 528 // PS_VECTOR_CHECK_NULL(dz, NULL); 517 529 518 530 psVector *zFit = NULL; … … 548 560 // XXX EAM : VectorFitPolynomial2DOrd and Polynomial2DEvalVector require different types (F32 vs F64) 549 561 550 # if (0) // moved to psLib 551 // XXX EAM : this version uses myPoly->nX as Norder, not Nterms 552 psF32 Polynomial2DEval(const psPolynomial2D* myPoly, 553 psF32 x, 554 psF32 y) 555 { 556 PS_POLY_CHECK_NULL(myPoly, NAN); 562 psF64 Polynomial2DEval(const psPolynomial2D* myPoly, 563 psF64 x, 564 psF64 y) 565 { 566 // PS_POLY_CHECK_NULL(myPoly, NAN); 557 567 558 568 psS32 loop_x = 0; 559 569 psS32 loop_y = 0; 560 psF 32polySum = 0.0;561 psF 32xSum = 1.0;562 psF 32ySum = 1.0;570 psF64 polySum = 0.0; 571 psF64 xSum = 1.0; 572 psF64 ySum = 1.0; 563 573 564 574 // XXX EAM : nX is order, not nTerms … … 577 587 return(polySum); 578 588 } 579 # endif580
Note:
See TracChangeset
for help on using the changeset viewer.
