Changeset 5180 for trunk/psLib/src/math
- Timestamp:
- Sep 29, 2005, 10:06:58 AM (21 years ago)
- Location:
- trunk/psLib/src/math
- Files:
-
- 2 edited
-
psPolynomial.c (modified) (2 diffs)
-
psSpline.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r5113 r5180 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.12 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-09-2 3 23:01:30$9 * @version $Revision: 1.129 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-29 20:06:58 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 784 784 } 785 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 786 808 psF64 psPolynomial1DEval(const psPolynomial1D* poly, 787 809 psF64 x) -
trunk/psLib/src/math/psSpline.c
r5179 r5180 7 7 * splines. 8 8 * 9 * @version $Revision: 1.13 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-09-29 19:40:59$9 * @version $Revision: 1.131 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-29 20:06:58 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 79 79 derivatives of the interpolating cubic splines at those n points. 80 80 81 The first and second derivatives at the endpoints, undefined in the SDR, are 82 here defined to be 0.0. They can be modified via ypo and yp1. 81 The first and second derivatives at the endpoints were previously undefined in 82 the SDR. From bugzilla #???, they are required to be 0.0, impementing natural 83 splines. 84 85 Endpoints are defined by 86 PS_LEFT_SPLINE_DERIV 87 PS_RIGHT_SPLINE_DERIV 83 88 84 89 This routine assumes that vectors x and y are of the appropriate types/sizes … … 89 94 XXX: do an F64 version? 90 95 *****************************************************************************/ 91 static psF32 *calculateSecondDerivs(const psVector* x, ///< Ordinates 92 const psVector* y) ///< Coordinates 96 #define PS_LEFT_SPLINE_DERIV 0.0 97 #define PS_RIGHT_SPLINE_DERIV 0.0 98 static psF32 *calculateSecondDerivs( 99 const psVector* x, ///< Ordinates 100 const psVector* y) ///< Coordinates 93 101 { 94 102 psTrace(__func__, 4, "---- %s() begin ----\n", __func__); 95 103 if (psTraceGetLevel(__func__) >= 6) { 96 PS_VECTOR_PRINT_F32(x);97 PS_VECTOR_PRINT_F32(y);104 p_psVectorPrint(1, (psVector *) x, "x"); 105 p_psVectorPrint(1, (psVector *) y, "y"); 98 106 } 99 107 psS32 n = y->n; … … 339 347 340 348 psS32 binNum; 341 unsigned intnumIntPoints = order+1;349 psS32 numIntPoints = order+1; 342 350 psS32 origin; 343 351 … … 460 468 return(tmpSpline); 461 469 } 462 463 470 464 471 /***************************************************************************** … … 481 488 482 489 XXX: What types must be supported? 483 484 XXX: Should we allow x==NULL?485 490 *****************************************************************************/ 486 491 psSpline1D *psVectorFitSpline1D( 487 const psVector* x, ///< Ordinates.488 const psVector* y) ///< Coordinates.492 const psVector* x, ///< Ordinates. 493 const psVector* y) ///< Coordinates. 489 494 { 490 495 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); … … 498 503 psVector *xPtr = NULL; 499 504 if (x != NULL) { 500 // Convert x to F32 if necessary.501 505 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 502 506 PS_ASSERT_VECTOR_TYPE_F32_OR_F64(x, NULL); 503 507 PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL); 508 // Convert x to F32 if necessary. 504 509 if (PS_TYPE_F64 == x->type.type) { 505 xPtr = psVectorAlloc(y->n, PS_TYPE_F32); 506 for (psS32 i = 0 ; i < x->n ; i++) { 507 xPtr->data.F32[i] = (psF32) x->data.F64[i]; 508 } 510 xPtr = psVectorCopy(NULL, x, PS_TYPE_F32); 509 511 } else if (PS_TYPE_F32 == x->type.type) { 510 512 xPtr = (psVector *) x; … … 513 515 // Allocate an index vector for x 514 516 xPtr = psVectorCreate(NULL, 0.0, (psF64) y->n, 1.0, PS_TYPE_F32); 515 printf("x, y is (%d, %d)\n", (psS32) xPtr->n, (psS32) y->n);516 xPtr = xPtr;517 517 } 518 518 … … 520 520 // Convert y to F32 if necessary. 521 521 if (PS_TYPE_F64 == y->type.type) { 522 yPtr = psVectorAlloc(y->n, PS_TYPE_F32); 523 for (psS32 i = 0 ; i < y->n ; i++) { 524 yPtr->data.F32[i] = (psF32) y->data.F64[i]; 525 } 522 yPtr = psVectorCopy(NULL, y, PS_TYPE_F32); 526 523 } else { 527 524 yPtr = (psVector *) y; … … 570 567 tmp+= xPtr->data.F32[i] / H; 571 568 tmp*= spline->p_psDeriv2[i+1] * H * H / 6.0; 572 (spline->spline[i]->coeff[0])+= tmp;569 spline->spline[i]->coeff[0]+= tmp; 573 570 574 571 // … … 594 591 // 595 592 // From (3) 596 spline->spline[i]->coeff[2] = ((spline->p_psDeriv2)[i])* 3.0 * xPtr->data.F32[i+1] / (6.0 * H);593 spline->spline[i]->coeff[2] = spline->p_psDeriv2[i] * 3.0 * xPtr->data.F32[i+1] / (6.0 * H); 597 594 // From (4) 598 (spline->spline[i]->coeff[2])-= (((spline->p_psDeriv2)[i+1]) * 3.0 * xPtr->data.F32[i] / (6.0 * H));595 spline->spline[i]->coeff[2]-= spline->p_psDeriv2[i+1] * 3.0 * xPtr->data.F32[i] / (6.0 * H); 599 596 600 597 // … … 602 599 // 603 600 // From (3) 604 spline->spline[i]->coeff[3] = - ((spline->p_psDeriv2)[i])/ (6.0 * H);601 spline->spline[i]->coeff[3] = -spline->p_psDeriv2[i] / (6.0 * H); 605 602 // From (4) 606 (spline->spline[i]->coeff[3])+= ((spline->p_psDeriv2)[i+1])/ (6.0 * H);603 spline->spline[i]->coeff[3]+= spline->p_psDeriv2[i+1] / (6.0 * H); 607 604 608 605 psTrace(__func__, 6, "(spline->spline[%u])->coeff[0] is %f\n", i, spline->spline[i]->coeff[0]);
Note:
See TracChangeset
for help on using the changeset viewer.
