Changeset 5094
- Timestamp:
- Sep 22, 2005, 12:22:15 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 3 edited
-
src/math/psPolynomial.c (modified) (7 diffs)
-
test/math/tst_psFunc10.c (modified) (3 diffs)
-
test/math/tst_psFunc11.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r5092 r5094 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.12 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-09-22 2 0:45:43$9 * @version $Revision: 1.126 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-22 22:22:15 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 161 161 used frequently and the data structure created here does not contain the 162 162 outer coefficients of the Chebyshev polynomials. 163 164 XXX: From the poly nOrder/nTerm changem the maxChebyPoly here is still nTerms, 165 not nOrder. 163 166 *****************************************************************************/ 164 static psPolynomial1D **createChebyshevPolys(unsigned int maxChebyPoly) 165 { 167 static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly) 168 { 169 //printf("createChebyshevPolys(%d)\n", maxChebyPoly); 166 170 PS_ASSERT_INT_NONNEGATIVE(maxChebyPoly, NULL); 167 171 … … 169 173 170 174 chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *)); 171 for ( unsigned inti = 0; i < maxChebyPoly; i++) {172 chebPolys[i] = psPolynomial1DAlloc(i , PS_POLYNOMIAL_ORD);175 for (psS32 i = 0; i < maxChebyPoly; i++) { 176 chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD); 173 177 } 174 178 … … 184 188 for (psS32 j = 0; j < chebPolys[i - 1]->COOL_1D_n; j++) { 185 189 chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j]; 190 //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j + 1, chebPolys[i]->coeff[j + 1]); 186 191 } 187 192 for (psS32 j = 0; j < chebPolys[i - 2]->COOL_1D_n; j++) { 188 193 chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j]; 194 //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j, chebPolys[i]->coeff[j]); 189 195 } 190 196 } … … 203 209 const psPolynomial1D* poly) 204 210 { 211 //printf("ordPolynomial1DEval(%f): ", x); 212 //for (psS32 i = 0 ; i < (1 + poly->COOL_1D_n) ; i++) printf("(%.2f) ", poly->coeff[i]); 213 //printf("\n"); 214 205 215 unsigned int loop_x = 0; 206 216 psF64 polySum = 0.0; … … 527 537 maxChebyPoly = poly->COOL_4D_nT; 528 538 } 539 // XXX: Add 1 since createChebyshevPolys() takes nTerms, not nOrder. 529 540 chebPolys = createChebyshevPolys(maxChebyPoly + 1); 530 541 … … 532 543 for (loop_y = 0; loop_y < (1 + poly->COOL_4D_nY); loop_y++) { 533 544 for (loop_z = 0; loop_z < (1 + poly->COOL_4D_nZ); loop_z++) { 534 for (loop_t = 0; loop_t < (1 + poly->COOL_4D_n Z); loop_t++) {545 for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nT); loop_t++) { 535 546 if (poly->mask[loop_x][loop_y][loop_z][loop_t] == 0) { 536 547 //printf("HMMM (%d, %d, %d, %d)\n", loop_x, loop_y, loop_z, loop_t); 537 548 //printf("HMMM (%d, %d, %d, %d)\n", chebPolys[loop_x]->COOL_1D_n, chebPolys[loop_y]->COOL_1D_n, chebPolys[loop_z]->COOL_1D_n, chebPolys[loop_t]->COOL_1D_n); 538 549 //printf("chebPolynomial4DEval()\n"); 539 550 polySum += poly->coeff[loop_x][loop_y][loop_z][loop_t] * 540 551 psPolynomial1DEval(chebPolys[loop_x], x) * -
trunk/psLib/test/math/tst_psFunc10.c
r5092 r5094 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * @date $Date: 2005-09-22 2 0:45:43$6 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2005-09-22 22:22:15 $ 8 8 * 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 184 184 psFree(polyOrd); 185 185 186 return 0;186 return(testStatus); 187 187 } 188 188 … … 320 320 psFree(polyCheb); 321 321 322 return 0;322 return(testStatus); 323 323 } 324 324 -
trunk/psLib/test/math/tst_psFunc11.c
r5092 r5094 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * @date $Date: 2005-09-22 2 0:45:43$6 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2005-09-22 22:22:15 $ 8 8 * 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 19 19 20 20 static psS32 testPoly4DEval(void); 21 //static psS32 testPoly4DEvalVector(void);21 static psS32 testPoly4DEvalVector(void); 22 22 23 23 testDescription tests[] = { 24 24 {testPoly4DEval,583,"psPolynomial4DEval",true,false}, 25 //{testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false},25 {testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false}, 26 26 {NULL} 27 27 }; … … 378 378 { 379 379 psBool testStatus = true; 380 381 380 // Allocate polynomial structure 382 381 psPolynomial4D* polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD); … … 405 404 testStatus = false; 406 405 } 407 408 406 psF64 resultCheb = psPolynomial4DEval(polyCheb,Dpoly4DWXYZChebValue[i][0],Dpoly4DWXYZChebValue[i][1], 409 407 Dpoly4DWXYZChebValue[i][2],Dpoly4DWXYZChebValue[i][3]); … … 431 429 return(testStatus); 432 430 } 433 /* 431 434 432 psS32 testPoly4DEvalVector(void) 435 433 { 434 psBool testStatus = true; 436 435 // Allocate polynomial 437 436 psPolynomial4D* polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD); 438 437 psPolynomial4D* polyCheb = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_CHEB); 439 438 440 439 // Set polynomial members 441 440 for(psS32 i = 0; i < TERMS; i++) { … … 451 450 } 452 451 } 453 452 454 453 // Create input vectors 455 454 psVector* inputOrdW = psVectorAlloc(TESTPOINTS, PS_TYPE_F64); … … 471 470 inputChebZ->data.F64[i] = Dpoly4DWXYZChebValue[i][3]; 472 471 } 473 472 474 473 // Evaluate the vectors 475 474 psVector* outputOrd = psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ); … … 480 479 if(outputOrd->type.type != PS_TYPE_F64) { 481 480 printf("TEST ERROR: Output vector of type %d expected %d", 482 outputOrd->type.type, PS_TYPE_F64);481 outputOrd->type.type, PS_TYPE_F64); 483 482 testStatus = false; 484 483 } … … 490 489 if(outputCheb->type.type != PS_TYPE_F64) { 491 490 printf("TEST ERROR: Output vector of type %d expected %d", 492 outputCheb->type.type, PS_TYPE_F64);493 testStatus = false; 494 } 495 491 outputCheb->type.type, PS_TYPE_F64); 492 testStatus = false; 493 } 494 496 495 // Verify the results 497 496 for(psS32 i = 0; i < TESTPOINTS; i++) { 498 497 if(fabs(Dpoly4DResult[i]-outputOrd->data.F64[i]) > ERROR_TOL) { 499 498 printf("TEST ERROR: Result[%d] %lg not equal to expected %lg", 500 i, outputOrd->data.F64[i], Dpoly4DResult[i]);499 i, outputOrd->data.F64[i], Dpoly4DResult[i]); 501 500 testStatus = false; 502 501 } 503 502 if(fabs(Dpoly4DChebResult[i]-outputCheb->data.F64[i]) > ERROR_TOL) { 504 503 printf("TEST ERROR: ResultCheb[%d] %lg not equal to expected %lg", 505 i, outputCheb->data.F64[i], Dpoly4DChebResult[i]);504 i, outputCheb->data.F64[i], Dpoly4DChebResult[i]); 506 505 testStatus = false; 507 506 } 508 507 } 509 508 510 509 // Attempt to invoke function with null polynomial 511 510 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL polynomial"); … … 514 513 testStatus = false; 515 514 } 516 515 517 516 // Attempt to invoke function with null input vector 518 517 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL input vector"); … … 539 538 testStatus = false; 540 539 } 541 540 542 541 // Attempt to invoke function with a non F64 type input vector 543 542 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid input type"); … … 572 571 } 573 572 inputOrdW->type.type = PS_TYPE_F64; 574 573 575 574 psFree(inputOrdX); 576 575 psFree(inputOrdY); … … 585 584 psFree(polyOrd); 586 585 psFree(polyCheb); 587 586 588 587 return(testStatus); 589 588 } 590 591 */
Note:
See TracChangeset
for help on using the changeset viewer.
