IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1985


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

Added F64 version of spline eval tests.

Location:
trunk/psLib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psFunctions.c

    r1982 r1985  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-06 21:30:53 $
     9 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-06 22:27:06 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    20652065 
    20662066XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
     2067 
     2068XXX: The spline eval functions require input and output to be F32.  however
     2069     the spline fit functions require F32 and F64.
    20672070 *****************************************************************************/
    20682071float psSpline1DEval(const psSpline1D *spline,
     
    20902093}
    20912094
     2095// XXX: The spline eval functions require input and output to be F32.
     2096// however the spline fit functions require F32 and F64.
    20922097psVector *psSpline1DEvalVector(const psVector *x,
    20932098                               const psSpline1D *spline)
     
    20972102
    20982103    tmpVector = psVectorAlloc(x->n, PS_TYPE_F32);
    2099     for (i=0;i<x->n;i++) {
    2100         tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2104    if (x->type.type == PS_TYPE_F32) {
     2105        for (i=0;i<x->n;i++) {
     2106            tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2107        }
     2108    } else if (x->type.type == PS_TYPE_F64) {
     2109        for (i=0;i<x->n;i++) {
     2110            tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]);
     2111        }
     2112    } else {
     2113        psError(__func__, "Unknown data type.\n");
     2114        return(NULL);
    21012115    }
    21022116
  • trunk/psLib/src/math/psPolynomial.c

    r1982 r1985  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-06 21:30:53 $
     9 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-06 22:27:06 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    20652065 
    20662066XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
     2067 
     2068XXX: The spline eval functions require input and output to be F32.  however
     2069     the spline fit functions require F32 and F64.
    20672070 *****************************************************************************/
    20682071float psSpline1DEval(const psSpline1D *spline,
     
    20902093}
    20912094
     2095// XXX: The spline eval functions require input and output to be F32.
     2096// however the spline fit functions require F32 and F64.
    20922097psVector *psSpline1DEvalVector(const psVector *x,
    20932098                               const psSpline1D *spline)
     
    20972102
    20982103    tmpVector = psVectorAlloc(x->n, PS_TYPE_F32);
    2099     for (i=0;i<x->n;i++) {
    2100         tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2104    if (x->type.type == PS_TYPE_F32) {
     2105        for (i=0;i<x->n;i++) {
     2106            tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2107        }
     2108    } else if (x->type.type == PS_TYPE_F64) {
     2109        for (i=0;i<x->n;i++) {
     2110            tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]);
     2111        }
     2112    } else {
     2113        psError(__func__, "Unknown data type.\n");
     2114        return(NULL);
    21012115    }
    21022116
  • trunk/psLib/src/math/psSpline.c

    r1982 r1985  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-06 21:30:53 $
     9 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-06 22:27:06 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    20652065 
    20662066XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
     2067 
     2068XXX: The spline eval functions require input and output to be F32.  however
     2069     the spline fit functions require F32 and F64.
    20672070 *****************************************************************************/
    20682071float psSpline1DEval(const psSpline1D *spline,
     
    20902093}
    20912094
     2095// XXX: The spline eval functions require input and output to be F32.
     2096// however the spline fit functions require F32 and F64.
    20922097psVector *psSpline1DEvalVector(const psVector *x,
    20932098                               const psSpline1D *spline)
     
    20972102
    20982103    tmpVector = psVectorAlloc(x->n, PS_TYPE_F32);
    2099     for (i=0;i<x->n;i++) {
    2100         tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2104    if (x->type.type == PS_TYPE_F32) {
     2105        for (i=0;i<x->n;i++) {
     2106            tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
     2107        }
     2108    } else if (x->type.type == PS_TYPE_F64) {
     2109        for (i=0;i<x->n;i++) {
     2110            tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]);
     2111        }
     2112    } else {
     2113        psError(__func__, "Unknown data type.\n");
     2114        return(NULL);
    21012115    }
    21022116
  • trunk/psLib/test/dataManip/tst_psFunc00.c

    r1811 r1985  
    33    allocated and deallocated by the psPolynomialXXXlloc() procedures.
    44    It also calls the various psPolynomialXXXEval() procedures.
     5 
     6    The F32 and F64 polynomials are tested for all orders (1 - 4) and for
     7    both ordinary and chebyshev polynomials.
     8 
     9    NOTE: This test code requries the stdout file to verify that the results
     10    are good.
    511 *****************************************************************************/
    612#include <stdio.h>
     
    1218#define MISC_X_VALUE 5.0
    1319#define MISC_INT_NUMBER 35
    14 #define NUM_BINS 200
    1520#define AN 2
    1621#define BN 4
     
    6065    }
    6166    printFooter(stdout,
    62                 "psStats functions",
     67                "psFunctions functions",
    6368                "Allocate/Deallocate the psPolynomial1D structure.",
    6469                testStatus);
     
    9095    }
    9196    printFooter(stdout,
    92                 "psStats functions",
     97                "psFunctions functions",
    9398                "Allocate/Deallocate the psPolynomial2D structure.",
    9499                testStatus);
     
    121126    }
    122127    printFooter(stdout,
    123                 "psStats functions",
     128                "psFunctions functions",
    124129                "Allocate/Deallocate the psPolynomial3D structure.",
    125130                testStatus);
     
    155160    }
    156161    printFooter(stdout,
    157                 "psStats functions",
     162                "psFunctions functions",
    158163                "Allocate/Deallocate the psPolynomial4D structure.",
    159164                testStatus);
     
    185190    }
    186191    printFooter(stdout,
    187                 "psStats functions",
     192                "psFunctions functions",
    188193                "Allocate/Deallocate the psDPolynomial1D structure.",
    189194                testStatus);
     
    211216    }
    212217    printFooter(stdout,
    213                 "psStats functions",
     218                "psFunctions functions",
    214219                "Allocate/Deallocate the psDPolynomial2D structure.",
    215220                testStatus);
     
    242247    }
    243248    printFooter(stdout,
    244                 "psStats functions",
     249                "psFunctions functions",
    245250                "Allocate/Deallocate the psDPolynomial3D structure.",
    246251                testStatus);
     
    276281    }
    277282    printFooter(stdout,
    278                 "psStats functions",
     283                "psFunctions functions",
    279284                "Allocate/Deallocate the psDPolynomial4D structure.",
    280285                testStatus);
     
    306311    }
    307312    printFooter(stdout,
    308                 "psStats functions",
     313                "psFunctions functions",
    309314                "Allocate/Deallocate the psPolynomial1D structure (CHEBYSHEV).",
    310315                testStatus);
     
    335340    }
    336341    printFooter(stdout,
    337                 "psStats functions",
     342                "psFunctions functions",
    338343                "Allocate/Deallocate the psPolynomial2D structure (CHEBYSHEV).",
    339344                testStatus);
     
    366371    }
    367372    printFooter(stdout,
    368                 "psStats functions",
     373                "psFunctions functions",
    369374                "Allocate/Deallocate the psPolynomial3D structure (CHEBYSHEV).",
    370375                testStatus);
     
    400405    }
    401406    printFooter(stdout,
    402                 "psStats functions",
     407                "psFunctions functions",
    403408                "Allocate/Deallocate the psPolynomial4D structure (CHEBYSHEV).",
    404409                testStatus);
     
    430435    }
    431436    printFooter(stdout,
    432                 "psStats functions",
     437                "psFunctions functions",
    433438                "Allocate/Deallocate the psDPolynomial1D structure (CHEBYSHEV).",
    434439                testStatus);
     
    456461    }
    457462    printFooter(stdout,
    458                 "psStats functions",
     463                "psFunctions functions",
    459464                "Allocate/Deallocate the psDPolynomial2D structure (CHEBYSHEV).",
    460465                testStatus);
     
    487492    }
    488493    printFooter(stdout,
    489                 "psStats functions",
     494                "psFunctions functions",
    490495                "Allocate/Deallocate the psDPolynomial3D structure (CHEBYSHEV).",
    491496                testStatus);
     
    521526    }
    522527    printFooter(stdout,
    523                 "psStats functions",
     528                "psFunctions functions",
    524529                "Allocate/Deallocate the psDPolynomial4D structure (CHEBYSHEV).",
    525530                testStatus);
  • 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.