IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5181 for trunk/psLib/test/math


Ignore:
Timestamp:
Sep 29, 2005, 10:20:32 AM (21 years ago)
Author:
gusciora
Message:

Additional tests for psSPline

Location:
trunk/psLib/test/math
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/tst_psSpline1D.c

    r5155 r5181  
    1313*  @author GLG, MHPCC
    1414*
    15 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    16 *  @date $Date: 2005-09-27 23:19:47 $
     15*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     16*  @date $Date: 2005-09-29 20:20:32 $
    1717*
    1818*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5454    psLogSetFormat("HLNM");
    5555    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    //
    6260    psTraceSetLevel(".", 0);
    6361    psTraceSetLevel("spline1DFree", 0);
     
    6664    psTraceSetLevel("vectorBinDisectF64", 0);
    6765    psTraceSetLevel("p_psVectorBinDisect", 0);
    68     psTraceSetLevel("fullInterpolate1DF32", 0);
    69     psTraceSetLevel("fullInterpolate1DF64", 0);
    70     psTraceSetLevel("interpolate1DF32", 0);
    71     psTraceSetLevel("p_psVectorInterpolate", 0);
    7266    psTraceSetLevel("psSpline1DAlloc", 0);
    7367    psTraceSetLevel("psVectorFitSpline1D", 0);
     
    7569    psTraceSetLevel("psSpline1DEvalVector", 0);
    7670
     71    return ( ! runTestSuite( stderr, "psSpline1D", tests, argc, argv ) );
     72}
     73
     74psS32 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
    7787    psS32 testStatus = true;
    7888    psS32  currentId = psMemGetId();
    79 
    80     printPositiveTestHeader(stdout, "psSpline functions", "psSpline1DAlloc()");
    8189
    8290    psSpline1D *tmpSpline = psSpline1DAlloc();
     
    113121    }
    114122
    115     printFooter(stdout, "psSpline functions", "psSpline1DAlloc()", testStatus);
    116123    return(testStatus);
    117124}
     
    119126
    120127/*********************************************************************************
    121 t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
     128psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
    122129simple x->y mapping (defined by myFunc00() below).  We do this for both F32
    123130and F64 versions of the input x and y vectors.
     
    128135}
    129136
    130 psS32 t00(psS32 NumSplines)
    131 {
    132     printf("t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n");
     137psS32 psSplineEvalTest_sub00(psS32 NumSplines)
     138{
     139    printf("\n");
     140    printf("psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very\n");
    133141    printf("simple x->y mapping (defined by myFunc00()).  We do this for both F32\n");
    134142    printf("and F64 versions of the input x and y vectors.\n");
     
    159167    }
    160168
    161     printPositiveTestHeader(stdout, "psSpline functions",
    162                             "psVectorFitSpline1D, psSpline1DEval(), F32, F32");
    163169
    164170    tmpSpline = psVectorFitSpline1D(xF32, yF32);
     
    221227        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    222228    }
    223     printFooter(stdout, "psSpline functions",
    224                 "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);
    225 
    226229    /****************************************************************************/
    227230    /*    PS_TYPE_F64, PS_TYPE_F64 test          */
     
    238241        yF64->data.F64[i] = (psF64) myFunc00(xF32->data.F32[i]);
    239242    }
    240 
    241     printPositiveTestHeader(stdout, "psSpline functions",
    242                             "psVectorFitSpline1D, psSpline1DEval(), F64, F64");
    243243
    244244    tmpSpline = psVectorFitSpline1D(xF64, yF64);
     
    301301        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    302302    }
    303     printFooter(stdout, "psSpline functions",
    304                 "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus);
    305 
    306303    return (testStatus);
    307304}
    308305
    309306/*********************************************************************************
    310 t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a
     307psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a
    311308more complicated x->y mapping (defined by myFunc00b() below).  We do this for
    312309both F32 and F64 versions of the input x and y vectors.
     
    321318}
    322319
    323 psS32 t00b(psS32 NumSplines)
    324 {
    325     printf("t00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n");
     320psS32 psSplineEvalTest_sub00b(psS32 NumSplines)
     321{
     322    printf("\n");
     323    printf("psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a\n");
    326324    printf("more complicated x->y mapping (defined by myFunc00b()).  We do this for\n");
    327325    printf("both F32 and F64 versions of the input x and y vectors.\n");
     
    352350    }
    353351
    354     printPositiveTestHeader(stdout, "psSpline functions",
    355                             "psVectorFitSpline1D, psSpline1DEval(), F32, F32");
    356 
    357352    tmpSpline = psVectorFitSpline1D(xF32, yF32);
    358353    if (tmpSpline == NULL) {
     
    414409        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    415410    }
    416     printFooter(stdout, "psSpline functions",
    417                 "psVectorFitSpline1D, psSpline1DEval(), F32, F32", testStatus);
    418 
    419411    /****************************************************************************/
    420412    /*    PS_TYPE_F64, PS_TYPE_F64 test          */
     
    431423        yF64->data.F64[i] = (psF64) myFunc00b(xF32->data.F32[i]);
    432424    }
    433 
    434     printPositiveTestHeader(stdout, "psSpline functions",
    435                             "psVectorFitSpline1D, psSpline1DEval(), F64, F64");
    436425
    437426    tmpSpline = psVectorFitSpline1D(xF64, yF64);
     
    494483        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    495484    }
    496     printFooter(stdout, "psSpline functions",
    497                 "psVectorFitSpline1D, psSpline1DEval(), F64, F64", testStatus);
    498 
     485    return (testStatus);
     486}
     487
     488
     489psS32 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    }
    499653    return (testStatus);
    500654}
     
    510664    psTraceSetLevel("vectorBinDisectF64", 0);
    511665    psTraceSetLevel("p_psVectorBinDisect", 0);
    512     psTraceSetLevel("fullInterpolate1DF32", 0);
    513     psTraceSetLevel("fullInterpolate1DF64", 0);
    514     psTraceSetLevel("interpolate1DF32", 0);
    515     psTraceSetLevel("p_psVectorInterpolate", 0);
    516666    psTraceSetLevel("psSpline1DAlloc", 0);
    517667    psTraceSetLevel("psVectorFitSpline1D", 0);
     
    519669    psTraceSetLevel("psSpline1DEvalVector", 0);
    520670
    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
     676psS32 psSplineEvalVectorTest_sub00(psS32 NumSplines)
    527677{
    528678    psS32 testStatus = true;
     
    546696        yF32->data.F32[i] = (psF32) i;
    547697    }
    548 
    549     printPositiveTestHeader(stdout, "psSpline functions",
    550                             "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32");
    551698
    552699    tmpSpline = psVectorFitSpline1D(xF32, yF32);
     
    630777        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    631778    }
    632     printFooter(stdout, "psSpline functions",
    633                 "psVectorFitSpline1D, psSpline1DEvalVector(), F32, F32", testStatus);
    634 
    635779    return (testStatus);
    636780}
     
    644788    psTraceSetLevel("vectorBinDisectF64", 0);
    645789    psTraceSetLevel("p_psVectorBinDisect", 0);
    646     psTraceSetLevel("fullInterpolate1DF32", 0);
    647     psTraceSetLevel("fullInterpolate1DF64", 0);
    648     psTraceSetLevel("interpolate1DF32", 0);
    649     psTraceSetLevel("p_psVectorInterpolate", 0);
    650790    psTraceSetLevel("psSpline1DAlloc", 0);
    651791    psTraceSetLevel("psVectorFitSpline1D", 0);
     
    653793    psTraceSetLevel("psSpline1DEvalVector", 0);
    654794
    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 \**********************************************************************************/
    61
    7 
    8 ---> TESTPOINT PASSED (psSpline functions{psSpline1DAlloc()} | tst_psSpline1D.c)
    9 
    10 t00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
     2psSplineEvalTest_sub00(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a very
    113simple x->y mapping (defined by myFunc00()).  We do this for both F32
    124and 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 \**********************************************************************************/
    185
    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
     6psSplineEvalTest_sub00b(): We test the psVectorFitSpline1D, psSpline1DEval() functions with a
    327more complicated x->y mapping (defined by myFunc00b()).  We do this for
    338both 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 \**********************************************************************************/
    399
    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 
     10psSplineEvalTest_sub00c(): This is similar to psSplineEvalTest_sub00b()
     11except that the x vector is NULL.
    5812Testing psSpline1DEvalVector() with an F32 vector.
    5913Testing 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.