Changeset 3988 for trunk/psLib/src/math/psSpline.c
- Timestamp:
- May 19, 2005, 12:53:47 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psSpline.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psSpline.c
r3884 r3988 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.10 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-05-1 1 22:02:16$9 * @version $Revision: 1.102 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-05-19 22:53:47 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 13 13 * 14 * XXX: What happens if the polyEval functions are called with data of the wrong15 * type?16 14 * XXX: Should the "coeffErr[]" be used as well? Bug ???. Ignore coeffErr 17 15 * 18 16 * XXX: In the various polyAlloc(n) functions, n is really the order of the 19 17 * polynomial plus 1. To create a 2nd-order polynomial, n == 3. 20 *21 * XXX: potential bug: for a multi-dimensional polynomial with order (m, n)22 * the functions in this file currently do not ignore many of the23 * coefficients in the coeff matrix that ...24 *25 18 */ 26 19 /*****************************************************************************/ … … 255 248 PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL); 256 249 250 printf("HERE: 00\n"); 251 257 252 psPolynomial1D **chebPolys = NULL; 258 253 … … 269 264 if (maxChebyPoly > 1) { 270 265 chebPolys[1]->coeff[1] = 1; 271 } 272 for (psS32 i = 2; i < maxChebyPoly; i++) { 273 for (psS32 j = 0; j < chebPolys[i - 1]->n; j++) { 274 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j]; 275 } 276 for (psS32 j = 0; j < chebPolys[i - 2]->n; j++) { 277 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j]; 278 } 266 267 for (psS32 i = 2; i < maxChebyPoly; i++) { 268 for (psS32 j = 0; j < chebPolys[i - 1]->n; j++) { 269 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j]; 270 } 271 for (psS32 j = 0; j < chebPolys[i - 2]->n; j++) { 272 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j]; 273 } 274 } 275 } else { 276 // XXX: Code this. 277 printf("WARNING: %d-order chebyshev polynomials not correctly implemented.\n", maxChebyPoly); 279 278 } 280 279 … … 318 317 { 319 318 PS_FLOAT_CHECK_RANGE(x, -1.0, 1.0, 0.0); 319 // XXX: Create a macro for this in psConstants.h 320 if (myPoly->n < 1) { 321 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: Chebyshev polynomial as order %d.", myPoly->n); 322 return(NAN); 323 } 320 324 psVector *d; 321 psS32 n ;325 psS32 n = myPoly->n; 322 326 psS32 i; 323 psF32 tmp; 324 325 n = myPoly->n; 327 psF32 tmp = 0.0; 328 329 // Special case where the Chebyshev poly is constant. 330 if (n == 1) { 331 if (myPoly->mask[0] == 0) { 332 tmp += myPoly->coeff[0]; 333 } 334 return(tmp); 335 } 336 337 // Special case where the Chebyshev poly is linear. 338 if (n == 2) { 339 if (myPoly->mask[0] == 0) { 340 tmp+= myPoly->coeff[0]; 341 } 342 if (myPoly->mask[1] == 0) { 343 tmp+= myPoly->coeff[1] * x; 344 } 345 return(tmp); 346 } 347 348 // General case where the Chebyshev poly has 2 or more terms. 326 349 d = psVectorAlloc(n, PS_TYPE_F32); 327 350 if(myPoly->mask[n-1] == 0) { … … 330 353 d->data.F32[n-1] = 0.0; 331 354 } 355 332 356 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]); 333 357 if(myPoly->mask[n-2] == 0) { 334 358 d->data.F32[n-2] += myPoly->coeff[n-2]; 335 359 } 360 336 361 for (i=n-3;i>=1;i--) { 337 362 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) - … … 350 375 return(tmp); 351 376 352 /* 377 /* This is old code that does not use Clenshaw's formula. Get rid of it. 353 378 354 379 psS32 n;
Note:
See TracChangeset
for help on using the changeset viewer.
