IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 28, 2006, 6:38:42 PM (19 years ago)
Author:
magnier
Message:

changed return value for psVectorFit functions to bool; now using stats->option to set FitClip

File:
1 edited

Legend:

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

    r10607 r10848  
    1313#include "psPolynomialUtils.h"
    1414
    15 psPolynomial4D *psVectorChiClipFitPolynomial4D(
     15bool psVectorChiClipFitPolynomial4D(
    1616    psPolynomial4D *poly,
    1717    psStats *stats,
     
    7575        int Nkeep = 0;
    7676
    77         poly = psVectorFitPolynomial4D (poly, mask, maskValue, f, fErr, x, y, z, t);
     77        if (!psVectorFitPolynomial4D (poly, mask, maskValue, f, fErr, x, y, z, t)) {
     78            psError(PS_ERR_UNKNOWN, true, "Could not fit a polynomial to the data.  Returning NULL.\n");
     79            psFree (resid);
     80            return false;
     81        }
     82
    7883        fit = psPolynomial4DEvalVector (poly, x, y, z, t);
     84        if (fit == NULL) {
     85            psError(PS_ERR_UNKNOWN, false, "Could not call psPolynomial4DEvalVector().  Returning NULL.\n");
     86            psFree(resid)
     87            return false;
     88        }
     89
    7990        resid = (psVector *) psBinaryOp (resid, (void *) f, "-", (void *) fit);
    8091
    8192        if (!psVectorStats (stats, resid, NULL, mask, maskValue)) {
    8293            psError(PS_ERR_UNKNOWN, false, "failed to measure vector stats");
    83             return NULL;
     94            psFree (fit);
     95            psFree (resid);
     96            return false;
    8497        }
    8598        psTrace (__func__, 5, "resid stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
     
    108121        }
    109122
    110         psTrace (__func__, 4, "keeping %d of %ld pts for fit\n",
    111                  Nkeep, x->n);
    112 
     123        psTrace (__func__, 4, "keeping %d of %ld pts for fit\n", Nkeep, x->n);
    113124        stats->clippedNvalues = Nkeep;
    114125        psFree (fit);
     
    117128    psFree (resid);
    118129
    119     if (poly == NULL) {
    120         psError(PS_ERR_UNKNOWN, true, "Could not fit a polynomial to the data.  Returning NULL.\n");
    121         return(NULL);
    122     }
    123     return(poly);
     130    return true;
    124131}
    125132
Note: See TracChangeset for help on using the changeset viewer.