IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 12, 2004, 9:50:34 AM (22 years ago)
Author:
gusciora
Message:

Added error codes, and corrected the return values in the polynomial
evaluation functions when the polynomial has an incorrect type.

The error stuff does not compile.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r2342 r2343  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-12 19:36:07 $
     11 *  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-12 19:50:34 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    992992                       float getThisValue)
    993993{
     994    PS_POLY_CHECK_NULL(myPoly, NAN);
    994995    PS_FLOAT_COMPARE(rangeLow, rangeHigh, NAN);
     996    // We ensure that the requested f(y) value, which is getThisValue, is
     997    // falls within the range of y-values of the polynomial "myPoly" in the
     998    // specified x-range (rangeLow:rangeHigh).
     999    float fLo = psPolynomial1DEval(rangeLow, myPoly);
     1000    float fHi = psPolynomial1DEval(rangeHigh, myPoly);
     1001    if (!((fLo <= getThisValue) && (fHi >= getThisValue))) {
     1002        psError(PS_ERR_UNKNOWN,
     1003                true,
     1004                psStats_STATS_POLY_MEDIAN_OUT_OF_RANGE);
     1005        return(NAN);
     1006    }
     1007
    9951008    psS32 numIterations = 0;
    9961009    float midpoint = 0.0;
     
    10731086        // Determine the coefficients of the polynomial.
    10741087        myPoly = psVectorFitPolynomial1D(myPoly, x, y, yErr);
     1088        if (myPoly == NULL) {
     1089            psError(PS_ERR_UNEXPECTED_NULL,
     1090                    false,
     1091                    psStats_STATS_FIT_QUADRATIC_POLYNOMIAL_1D_FIT);
     1092            return(NAN);
     1093        }
    10751094        // Call p_ps1DPolyMedian(), which does a binary search on the
    10761095        // polynomial, looking for the value x such that f(x) = yVal
Note: See TracChangeset for help on using the changeset viewer.