IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2004, 12:27:06 PM (22 years ago)
Author:
gusciora
Message:

Added F64 version of spline eval tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psFunc07.c

    r1982 r1985  
    44values, sets the spline polynomials with psVectorFitSpline1D(), then calls
    55psSpline1DEval() on new data values and ensures that the results are correct.
     6 
     7F32 and F64 versions are used here.
     8 
     9XXX: The spline eval functions are F32 only, while the spline fit functions
     10are F32 and F64.
    611 *****************************************************************************/
    712#include <stdio.h>
     
    6267    printPositiveTestHeader(stdout,
    6368                            "psFunction functions",
    64                             "psSpline1DAlloc()");
     69                            "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F32 versions");
    6570
    6671    psVectorFitSpline1D(tmpSpline, x, y, NULL);
     
    7176            printf("ERROR[%d]: f(%f) is %f.  Should be %f\n", i,
    7277                   newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i]));
     78            testStatus = false;
    7379        }
    7480    }
     
    8894    printFooter(stdout,
    8995                "psFunctions functions",
    90                 "psSpline1DAlloc()",
     96                "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F32 versions",
    9197                testStatus);
    9298
     
    94100}
    95101
    96 int t00()
     102// This is the F64 version of the above test code.
     103int t01()
    97104{
    98105    int testStatus = true;
     
    110117    /****************************************************************************/
    111118    testStatus = true;
    112     x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
    113     newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
    114     y = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
     119    x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64);
     120    newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64);
     121    y = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64);
    115122    tmpSpline = psSpline1DAlloc(NUM_SPLINES, 3, MIN, MAX);
    116123
    117124    for (i=0;i<NUM_SPLINES+1;i++) {
    118         x->data.F32[i] = tmpSpline->domains[i];
    119         y->data.F32[i] = myFunc(x->data.F32[i]);
     125        x->data.F64[i] = tmpSpline->domains[i];
     126        y->data.F64[i] = myFunc(x->data.F64[i]);
    120127    }
    121128
    122129    for (i=0;i<NUM_SPLINES;i++) {
    123         newX->data.F32[i]= ((x->data.F32[i] + x->data.F32[i+1])/2.0);
     130        newX->data.F64[i]= ((x->data.F64[i] + x->data.F64[i+1])/2.0);
    124131    }
    125     newX->data.F32[NUM_SPLINES] = x->data.F32[NUM_SPLINES];
     132    newX->data.F64[NUM_SPLINES] = x->data.F64[NUM_SPLINES];
    126133    /****************************************************************************/
    127134    /*   psLib Code      */
     
    129136    printPositiveTestHeader(stdout,
    130137                            "psFunction functions",
    131                             "psSpline1DAlloc()");
     138                            "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F64 versions");
    132139
    133140    psVectorFitSpline1D(tmpSpline, x, y, NULL);
     
    135142
    136143    for (i=OFFSET;i<NUM_SPLINES-OFFSET+1;i++) {
    137         if ( fabs( newY->data.F32[i] - myFunc(newX->data.F32[i]) ) > fabs( ERROR_TOLERANCE * myFunc(newX->data.F32[i]) ) ) {
     144        if ( fabs( newY->data.F32[i] - myFunc(newX->data.F64[i]) ) > fabs( ERROR_TOLERANCE * myFunc((float)newX->data.F64[i]) ) ) {
    138145            printf("ERROR[%d]: f(%f) is %f.  Should be %f\n", i,
    139                    newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i]));
     146                   newX->data.F64[i], newY->data.F32[i], myFunc((float)newX->data.F64[i]));
     147            testStatus = false;
    140148        }
    141149    }
     
    155163    printFooter(stdout,
    156164                "psFunctions functions",
    157                 "psSpline1DAlloc()",
     165                "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F64 versions",
    158166                testStatus);
    159167
     
    164172{
    165173    t00();
     174    t01();
    166175}
Note: See TracChangeset for help on using the changeset viewer.