IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12340


Ignore:
Timestamp:
Mar 8, 2007, 1:24:48 PM (19 years ago)
Author:
rhl
Message:

In fitQuadraticSearchForYThenReturnX() the fit is y(x) so it is
x that must be monotonic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel-1_0/psLib/src/math/psStats.c

    r11155 r12340  
    1313 * use ->min and ->max (PS_STAT_USE_RANGE)
    1414 *
    15  *  @version $Revision: 1.199 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-01-19 04:32:27 $
     15 *  @version $Revision: 1.199.2.1 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-03-08 23:24:48 $
    1717 *
    1818 *  Copyright 2006 IfA, University of Hawaii
     
    21582158
    21592159        //
    2160         // Ensure that the y values are monotonic.
     2160        // Ensure that the x values are monotonic.
    21612161        //
    2162         if (((y->data.F64[0] < y->data.F64[1]) && !(y->data.F64[1] <= y->data.F64[2])) ||
    2163                 ((y->data.F64[0] > y->data.F64[1]) && !(y->data.F64[1] >= y->data.F64[2]))) {
     2162        if (!(x->data.F64[0] < x->data.F64[1] && x->data.F64[1] < x->data.F64[2])) {
    21642163            psError(PS_ERR_UNKNOWN, true,
    2165                     "This routine must be called with monotonically increasing or decreasing data points.\n");
     2164                    "This routine must be called with monotonically increasing ordinates.\n");
    21662165            psFree(x);
    21672166            psFree(y);
     
    21722171        // Determine the coefficients of the polynomial.
    21732172        psPolynomial1D *myPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2);
    2174         if (!psVectorFitPolynomial1D(myPoly, NULL, 0, y, NULL, x)) {
     2173        if (!psVectorFitPolynomial1D(myPoly, NULL, 0, y, NULL, x)) { // fit y(x)
    21752174            psError(PS_ERR_UNEXPECTED_NULL, false,
    21762175                    _("Failed to fit a 1-dimensional polynomial to the three specified data points.  Returning NAN."));
     
    21832182        psTrace("psLib.math", 6, "myPoly->coeff[1] is %f\n", myPoly->coeff[1]);
    21842183        psTrace("psLib.math", 6, "myPoly->coeff[2] is %f\n", myPoly->coeff[2]);
    2185         psTrace("psLib.math", 6, "Fitted y vec is (%f %f %f)\n",
    2186                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[0]),
    2187                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[1]),
    2188                 (psF32) psPolynomial1DEval(myPoly, (psF64) x->data.F64[2]));
     2184        psTrace("psLib.math", 6, "Fitted x vec is (%f %f %f)\n",
     2185                (psF32) psPolynomial1DEval(myPoly, (psF64) y->data.F64[0]),
     2186                (psF32) psPolynomial1DEval(myPoly, (psF64) y->data.F64[1]),
     2187                (psF32) psPolynomial1DEval(myPoly, (psF64) y->data.F64[2]));
    21892188
    21902189        psTrace("psLib.math", 6, "We fit the polynomial, now find x such that f(x) equals %f\n", yVal);
Note: See TracChangeset for help on using the changeset viewer.