Changeset 5181
- Timestamp:
- Sep 29, 2005, 10:20:32 AM (21 years ago)
- Location:
- trunk/psLib/test/math
- Files:
-
- 2 edited
-
tst_psSpline1D.c (modified) (22 diffs)
-
verified/tst_psSpline1D.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tst_psSpline1D.c
r5155 r5181 13 13 * @author GLG, MHPCC 14 14 * 15 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $16 * @date $Date: 2005-09-2 7 23:19:47$15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2005-09-29 20:20:32 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 psLogSetFormat("HLNM"); 55 55 psLogSetLevel( PS_LOG_INFO ); 56 57 return ( ! runTestSuite( stderr, "psSpline1D", tests, argc, argv ) ); 58 } 59 60 psS32 psSplineAllocTest() 61 { 56 // 57 // Set the following trace leevls to track what is happening in the 58 // various functions in psSpline.c 59 // 62 60 psTraceSetLevel(".", 0); 63 61 psTraceSetLevel("spline1DFree", 0); … … 66 64 psTraceSetLevel("vectorBinDisectF64", 0); 67 65 psTraceSetLevel("p_psVectorBinDisect", 0); 68 psTraceSetLevel("fullInterpolate1DF32", 0);69 psTraceSetLevel("fullInterpolate1DF64", 0);70 psTraceSetLevel("interpolate1DF32", 0);71 psTraceSetLevel("p_psVectorInterpolate", 0);72 66 psTraceSetLevel("psSpline1DAlloc", 0); 73 67 psTraceSetLevel("psVectorFitSpline1D", 0); … … 75 69 psTraceSetLevel("psSpline1DEvalVector", 0); 76 70 71 return ( ! runTestSuite( stderr, "psSpline1D", tests, argc, argv ) ); 72 } 73 74 psS32 psSplineAllocTest() 75 { 76 psTraceSetLevel(".", 0); 77 psTraceSetLevel("spline1DFree", 0); 78 psTraceSetLevel("calculateSecondDerivs", 0); 79 psTraceSetLevel("vectorBinDisectF32", 0); 80 psTraceSetLevel("vectorBinDisectF64", 0); 81 psTraceSetLevel("p_psVectorBinDisect", 0); 82 psTraceSetLevel("psSpline1DAlloc", 0); 83 psTraceSetLevel("psVectorFitSpline1D", 0); 84 psTraceSetLevel("psSpline1DEval", 0); 85 psTraceSetLevel("psSpline1DEvalVector", 0); 86 77 87 psS32 testStatus = true; 78 88 psS32 currentId = psMemGetId(); 79 80 printPositiveTestHeader(stdout, "psSpline functions", "psSpline1DAlloc()");81 89 82 90 psSpline1D *tmpSpline = psSpline1DAlloc(); … … 113 121 } 114 122 115 printFooter(stdout, "psSpline functions", "psSpline1DAlloc()", testStatus);116 123 return(testStatus); 117 124 } … … 119 126 120 127 /********************************************************************************* 121 t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very128 psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very 122 129 simple x->y mapping (defined by myFunc00() below). We do this for both F32 123 130 and F64 versions of the input x and y vectors. … … 128 135 } 129 136 130 psS32 t00(psS32 NumSplines) 131 { 132 printf("t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n"); 137 psS32 psSplineEvalTest_sub00(psS32 NumSplines) 138 { 139 printf("\n"); 140 printf("psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n"); 133 141 printf("simple x->y mapping (defined by myFunc00()). We do this for both F32\n"); 134 142 printf("and F64 versions of the input x and y vectors.\n"); … … 159 167 } 160 168 161 printPositiveTestHeader(stdout, "psSpline functions",162 "psVectorFitSpline1D, psSpline1DEval(), F32, F32");163 169 164 170 tmpSpline = psVectorFitSpline1D(xF32, yF32); … … 221 227 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 222 228 } 223 printFooter(stdout, "psSpline functions",224 "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);225 226 229 /****************************************************************************/ 227 230 /* PS_TYPE_F64, PS_TYPE_F64 test */ … … 238 241 yF64->data.F64[i] = (psF64) myFunc00(xF32->data.F32[i]); 239 242 } 240 241 printPositiveTestHeader(stdout, "psSpline functions",242 "psVectorFitSpline1D, psSpline1DEval(), F64, F64");243 243 244 244 tmpSpline = psVectorFitSpline1D(xF64, yF64); … … 301 301 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 302 302 } 303 printFooter(stdout, "psSpline functions",304 "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus);305 306 303 return (testStatus); 307 304 } 308 305 309 306 /********************************************************************************* 310 t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a307 psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a 311 308 more complicated x->y mapping (defined by myFunc00b() below). We do this for 312 309 both F32 and F64 versions of the input x and y vectors. … … 321 318 } 322 319 323 psS32 t00b(psS32 NumSplines) 324 { 325 printf("t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n"); 320 psS32 psSplineEvalTest_sub00b(psS32 NumSplines) 321 { 322 printf("\n"); 323 printf("psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n"); 326 324 printf("more complicated x->y mapping (defined by myFunc00b()). We do this for\n"); 327 325 printf("both F32 and F64 versions of the input x and y vectors.\n"); … … 352 350 } 353 351 354 printPositiveTestHeader(stdout, "psSpline functions",355 "psVectorFitSpline1D, psSpline1DEval(), F32, F32");356 357 352 tmpSpline = psVectorFitSpline1D(xF32, yF32); 358 353 if (tmpSpline == NULL) { … … 414 409 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 415 410 } 416 printFooter(stdout, "psSpline functions",417 "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);418 419 411 /****************************************************************************/ 420 412 /* PS_TYPE_F64, PS_TYPE_F64 test */ … … 431 423 yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]); 432 424 } 433 434 printPositiveTestHeader(stdout, "psSpline functions",435 "psVectorFitSpline1D, psSpline1DEval(), F64, F64");436 425 437 426 tmpSpline = psVectorFitSpline1D(xF64, yF64); … … 494 483 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 495 484 } 496 printFooter(stdout, "psSpline functions", 497 "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus); 498 485 return (testStatus); 486 } 487 488 489 psS32 psSplineEvalTest_sub00c(psS32 NumSplines) 490 { 491 printf("\n"); 492 printf("psSplineEvalTest_sub00c(): This is similar to psSplineEvalTest_sub00b()\n"); 493 printf("except that the x vector is NULL.\n"); 494 psS32 testStatus = true; 495 psS32 memLeaks=0; 496 psF32 x; 497 psF32 y; 498 psS32 currentId = psMemGetId(); 499 psVector *xF32 = NULL; 500 psVector *xF64 = NULL; 501 psVector *yF32 = NULL; 502 psVector *yF64 = NULL; 503 psSpline1D *tmpSpline = NULL; 504 505 /****************************************************************************/ 506 /* PS_TYPE_F32, PS_TYPE_F32 test */ 507 /****************************************************************************/ 508 xF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32); 509 xF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64); 510 yF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32); 511 yF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64); 512 513 for (psS32 i=0;i<NumSplines+1;i++) { 514 xF32->data.F32[i] = (psF32) i; 515 xF64->data.F64[i] = (psF64) i; 516 yF32->data.F32[i] = (psF32) myFunc00b(xF32->data.F32[i]); 517 yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]); 518 } 519 520 tmpSpline = psVectorFitSpline1D(NULL, yF32); 521 if (tmpSpline == NULL) { 522 printf("TEST ERROR: Could not allocate psSpline1D data structure\n"); 523 testStatus = false; 524 } 525 526 if (tmpSpline->n != NumSplines) { 527 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->n member.\n"); 528 printf(" psSpline1D->NumSplines was %d, should be %d.\n", tmpSpline->n, NumSplines); 529 testStatus = false; 530 } 531 532 if (tmpSpline->spline == NULL) { 533 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline member.\n"); 534 testStatus = false; 535 } else { 536 for (psS32 i = 0 ; i < NumSplines ; i++) { 537 if (tmpSpline->spline[i] == NULL) { 538 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline[%d] member.\n", i); 539 testStatus = false; 540 } else { 541 if (psTraceGetLevel(__func__) >= 6) { 542 PS_POLY_PRINT_1D(tmpSpline->spline[i]); 543 } 544 } 545 } 546 } 547 548 if (tmpSpline->knots == NULL) { 549 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->knots member.\n"); 550 testStatus = false; 551 } 552 553 if (tmpSpline->p_psDeriv2 == NULL) { 554 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->p_psDeriv2 member.\n"); 555 testStatus = false; 556 } 557 558 if (testStatus == true) { 559 for (psS32 i=0;i<NumSplines;i++) { 560 x = 0.5 + (float) i; 561 y = psSpline1DEval(tmpSpline, x); 562 if (CheckErrorF32(y, myFunc00b(x))) { 563 printf("TEST ERROR: f(%f) is %f, should be %f\n", x, y, myFunc00b(x)); 564 testStatus = false; 565 } 566 } 567 } 568 569 psFree(tmpSpline); 570 psFree(xF32); 571 psFree(xF64); 572 psFree(yF32); 573 psFree(yF64); 574 psMemCheckCorruption(1); 575 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 576 if (0 != memLeaks) { 577 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 578 } 579 /****************************************************************************/ 580 /* PS_TYPE_F64, PS_TYPE_F64 test */ 581 /****************************************************************************/ 582 xF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32); 583 xF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64); 584 yF32 = psVectorAlloc(NumSplines+1, PS_TYPE_F32); 585 yF64 = psVectorAlloc(NumSplines+1, PS_TYPE_F64); 586 587 for (psS32 i=0;i<NumSplines+1;i++) { 588 xF32->data.F32[i] = (psF32) i; 589 xF64->data.F64[i] = (psF64) i; 590 yF32->data.F32[i] = (psF32) myFunc00b(xF32->data.F32[i]); 591 yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]); 592 } 593 594 tmpSpline = psVectorFitSpline1D(NULL, yF64); 595 if (tmpSpline == NULL) { 596 printf("TEST ERROR: Could not allocate psSpline1D data structure\n"); 597 testStatus = false; 598 } 599 600 if (tmpSpline->n != NumSplines) { 601 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->n member.\n"); 602 printf(" psSpline1D->NumSplines was %d, should be %d.\n", tmpSpline->n, NumSplines); 603 testStatus = false; 604 } 605 606 if (tmpSpline->spline == NULL) { 607 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline member.\n"); 608 testStatus = false; 609 } else { 610 for (psS32 i = 0 ; i < NumSplines ; i++) { 611 if (tmpSpline->spline[i] == NULL) { 612 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->spline[%d] member.\n", i); 613 testStatus = false; 614 } else { 615 if (psTraceGetLevel(__func__) >= 6) { 616 PS_POLY_PRINT_1D(tmpSpline->spline[i]); 617 } 618 } 619 } 620 } 621 622 if (tmpSpline->knots == NULL) { 623 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->knots member.\n"); 624 testStatus = false; 625 } 626 627 if (tmpSpline->p_psDeriv2 == NULL) { 628 printf("TEST ERROR: psVectorFitSpline1D() did not properly set the psSpline1D->p_psDeriv2 member.\n"); 629 testStatus = false; 630 } 631 632 if (testStatus == true) { 633 for (psS32 i=0;i<NumSplines;i++) { 634 x = 0.5 + (float) i; 635 y = psSpline1DEval(tmpSpline, x); 636 if (CheckErrorF32(y, myFunc00b(x))) { 637 printf("TEST ERROR: f(%f) is %f, should be %f\n", x, y, myFunc00b(x)); 638 testStatus = false; 639 } 640 } 641 } 642 643 psFree(tmpSpline); 644 psFree(xF32); 645 psFree(xF64); 646 psFree(yF32); 647 psFree(yF64); 648 psMemCheckCorruption(1); 649 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 650 if (0 != memLeaks) { 651 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 652 } 499 653 return (testStatus); 500 654 } … … 510 664 psTraceSetLevel("vectorBinDisectF64", 0); 511 665 psTraceSetLevel("p_psVectorBinDisect", 0); 512 psTraceSetLevel("fullInterpolate1DF32", 0);513 psTraceSetLevel("fullInterpolate1DF64", 0);514 psTraceSetLevel("interpolate1DF32", 0);515 psTraceSetLevel("p_psVectorInterpolate", 0);516 666 psTraceSetLevel("psSpline1DAlloc", 0); 517 667 psTraceSetLevel("psVectorFitSpline1D", 0); … … 519 669 psTraceSetLevel("psSpline1DEvalVector", 0); 520 670 521 return( t00(100) & t00b(100));522 } 523 524 525 526 psS32 t01(psS32 NumSplines)671 return(psSplineEvalTest_sub00(95) & psSplineEvalTest_sub00b(95) & psSplineEvalTest_sub00c(95)); 672 } 673 674 675 676 psS32 psSplineEvalVectorTest_sub00(psS32 NumSplines) 527 677 { 528 678 psS32 testStatus = true; … … 546 696 yF32->data.F32[i] = (psF32) i; 547 697 } 548 549 printPositiveTestHeader(stdout, "psSpline functions",550 "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32");551 698 552 699 tmpSpline = psVectorFitSpline1D(xF32, yF32); … … 630 777 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 631 778 } 632 printFooter(stdout, "psSpline functions",633 "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32", testStatus);634 635 779 return (testStatus); 636 780 } … … 644 788 psTraceSetLevel("vectorBinDisectF64", 0); 645 789 psTraceSetLevel("p_psVectorBinDisect", 0); 646 psTraceSetLevel("fullInterpolate1DF32", 0);647 psTraceSetLevel("fullInterpolate1DF64", 0);648 psTraceSetLevel("interpolate1DF32", 0);649 psTraceSetLevel("p_psVectorInterpolate", 0);650 790 psTraceSetLevel("psSpline1DAlloc", 0); 651 791 psTraceSetLevel("psVectorFitSpline1D", 0); … … 653 793 psTraceSetLevel("psSpline1DEvalVector", 0); 654 794 655 return(t01(10)); 656 } 657 658 659 660 //is the way 795 return(psSplineEvalVectorTest_sub00(10)); 796 } 797 798 -
trunk/psLib/test/math/verified/tst_psSpline1D.stdout
r5155 r5181 1 /***************************** TESTPOINT ******************************************\2 * TestFile: tst_psSpline1D.c *3 * TestPoint: psSpline functions{psSpline1DAlloc()} *4 * TestType: Positive *5 \**********************************************************************************/6 1 7 8 ---> TESTPOINT PASSED (psSpline functions{psSpline1DAlloc()} | tst_psSpline1D.c) 9 10 t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very 2 psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very 11 3 simple x->y mapping (defined by myFunc00()). We do this for both F32 12 4 and F64 versions of the input x and y vectors. 13 /***************************** TESTPOINT ******************************************\14 * TestFile: tst_psSpline1D.c *15 * TestPoint: psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F32, F32} *16 * TestType: Positive *17 \**********************************************************************************/18 5 19 20 ---> TESTPOINT PASSED (psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F32, F32} | tst_psSpline1D.c) 21 22 /***************************** TESTPOINT ******************************************\ 23 * TestFile: tst_psSpline1D.c * 24 * TestPoint: psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F64, F64} * 25 * TestType: Positive * 26 \**********************************************************************************/ 27 28 29 ---> TESTPOINT PASSED (psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F64, F64} | tst_psSpline1D.c) 30 31 t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a 6 psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a 32 7 more complicated x->y mapping (defined by myFunc00b()). We do this for 33 8 both F32 and F64 versions of the input x and y vectors. 34 /***************************** TESTPOINT ******************************************\35 * TestFile: tst_psSpline1D.c *36 * TestPoint: psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F32, F32} *37 * TestType: Positive *38 \**********************************************************************************/39 9 40 41 ---> TESTPOINT PASSED (psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F32, F32} | tst_psSpline1D.c) 42 43 /***************************** TESTPOINT ******************************************\ 44 * TestFile: tst_psSpline1D.c * 45 * TestPoint: psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F64, F64} * 46 * TestType: Positive * 47 \**********************************************************************************/ 48 49 50 ---> TESTPOINT PASSED (psSpline functions{psVectorFitSpline1D, psSpline1DEval(), F64, F64} | tst_psSpline1D.c) 51 52 /***************************** TESTPOINT ******************************************\ 53 * TestFile: tst_psSpline1D.c * 54 * TestPoint: psSpline functions{psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32} * 55 * TestType: Positive * 56 \**********************************************************************************/ 57 10 psSplineEvalTest_sub00c(): This is similar to psSplineEvalTest_sub00b() 11 except that the x vector is NULL. 58 12 Testing psSpline1DEvalVector() with an F32 vector. 59 13 Testing psSpline1DEvalVector() with an F64 vector. 60 61 ---> TESTPOINT PASSED (psSpline functions{psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32} | tst_psSpline1D.c)62
Note:
See TracChangeset
for help on using the changeset viewer.
