IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10274


Ignore:
Timestamp:
Nov 29, 2006, 7:55:25 AM (20 years ago)
Author:
rhl
Message:

1/ vectorFittedStats and vectorRobustStats don't own mask and shouldn't free it
2/ Made vectorRobustStats propagate errors in vectorFittedStats
3/ psVectorStats doesn't own stats and shouldn't free it.

File:
1 edited

Legend:

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

    r10173 r10274  
    1616 * use ->min and ->max (PS_STAT_USE_RANGE)
    1717 *
    18  *  @version $Revision: 1.190 $ $Name: not supported by cvs2svn $
    19  *  @date $Date: 2006-11-23 05:33:28 $
     18 *  @version $Revision: 1.191 $ $Name: not supported by cvs2svn $
     19 *  @date $Date: 2006-11-29 17:55:25 $
    2020 *
    2121 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    11031103        psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
    11041104        psFree(statsMinMax);
    1105         psFree(mask);
    11061105        psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    11071106        return false;
     
    11571156        psFree(statsMinMax);
    11581157        psFree(histogram);
    1159         psFree(mask);
    11601158        psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    11611159        return false;
     
    11951193        psError(PS_ERR_UNKNOWN, false, "Failed to fit a gaussian to the robust histogram.\n");
    11961194        psFree(statsMinMax);
     1195        psFree(histogram);
    11971196        psFree(x);
    11981197        psFree(y);
    11991198        psFree(minimizer);
    12001199        psFree(params);
    1201         psFree(mask);
    12021200        psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    12031201        return false;
     
    12941292            psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
    12951293            psFree(statsMinMax);
    1296             psFree(mask);
    12971294            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    12981295            return false;
     
    13121309            stats->robustN50 = numValid;
    13131310            psFree(statsMinMax);
    1314             psFree(mask);
    13151311
    13161312            psTrace("psLib.math", 4, "---- %s(0) end  ----\n", __func__);
     
    13711367                psFree(histogram);
    13721368                psFree(cumulative);
    1373                 psFree(mask);
    13741369                psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    13751370                return false;
     
    13881383            psFree(histogram);
    13891384            psFree(cumulative);
    1390             psFree(mask);
    13911385            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    13921386            return false;
     
    14241418            psFree(histogram);
    14251419            psFree(cumulative);
    1426             psFree(mask);
    14271420            psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    14281421            return false;
     
    15431536        psFree(statsMinMax);
    15441537        psFree(cumulative);
    1545         psFree(mask);
    15461538        psTrace("psLib.math", 4, "---- %s(false) end  ----\n", __func__);
    15471539        return false;
     
    15611553                "could not determine the robustUQ: fitQuadraticSearchForYThenReturnX() returned a NAN.\n");
    15621554        psFree(statsMinMax);
    1563         psFree(mask);
    15641555        psTrace("psLib.math", 4, "---- %s(1) end  ----\n", __func__);
    15651556        return false;
     
    15841575        stats->fittedStdev = stats->robustStdev;  // pass the guess sigma
    15851576        stats->fittedMean = stats->robustMedian;  // pass the guess mean
    1586         vectorFittedStats (myVector, errors, mask, maskVal, stats);
     1577        if (!vectorFittedStats(myVector, errors, mask, maskVal, stats)) {
     1578            psError(PS_ERR_UNKNOWN, false, "Unable to estimate statistics (pass 1)");
     1579            psFree(statsMinMax);
     1580            psFree(mask);
     1581
     1582            return false;
     1583        }
    15871584        // if there is a large swing in sigma, try a second time
    15881585        if ((stats->fittedStdev/stats->robustStdev) < 0.75) {
    1589             vectorFittedStats (myVector, errors, mask, maskVal, stats);
     1586            if (!vectorFittedStats (myVector, errors, mask, maskVal, stats)) {
     1587                psError(PS_ERR_UNKNOWN, false, "Unable to estimate statistics (pass 2)");
     1588                psFree(statsMinMax);
     1589                psFree(mask);
     1590
     1591                return false;
     1592            }
    15901593        }
    15911594    }
     
    19661969    The stats structure.
    19671970 
    1968 XXX: Should we free stats if the asserts fail?
     1971XXX: Should we free stats if the asserts fail? NO; we don't own it (RHL).
    19691972 *****************************************************************************/
    19701973psStats* psVectorStats(
     
    20522055        if (!vectorRobustStats(inF32, errorsF32, maskU8, maskVal, stats)) {
    20532056            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate the specified statistic."));
    2054             psFree(stats);
    20552057            psFree(inF32);
    20562058            psFree(errorsF32);
Note: See TracChangeset for help on using the changeset viewer.