IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 23, 2007, 4:06:51 PM (19 years ago)
Author:
Paul Price
Message:

Make psStatsAlloc a macro, to deliver filename and line number information to the memory system, as most other allocators do. This is an ABI-incompatible change.

File:
1 edited

Legend:

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

    r13418 r13494  
    1313 * use ->min and ->max (PS_STAT_USE_RANGE)
    1414 *
    15  *  @version $Revision: 1.210 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-05-18 13:19:55 $
     15 *  @version $Revision: 1.211 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-05-24 02:06:51 $
    1717 *
    1818 *  Copyright 2006 IfA, University of Hawaii
     
    259259    for (long i = 0; i < num; i++) {
    260260        // Check if the data is with the specified range
    261         if (!isfinite(vector[i])) {
    262             stats->max = stats->min = NAN;
    263             psError(PS_ERR_IEEE, true, "Element %ld of vector is Inf/NaN", i);
    264             return 0;
    265         }
    266        
     261        if (!isfinite(vector[i])) {
     262            stats->max = stats->min = NAN;
     263            psError(PS_ERR_IEEE, true, "Element %ld of vector is Inf/NaN", i);
     264            return 0;
     265        }
     266
    267267        if (useRange && (vector[i] < stats->min))
    268268            continue;
     
    688688        }
    689689        psTrace(TRACE, 6, "Data min/max is (%.2f, %.2f)\n", min, max);
    690         assert (iterate < 20);
     690        assert (iterate < 20);
    691691        // fprintf (stderr, "%d @ %d : %f - %f\n", iterate, numValid, min, max);
    692692
     
    16611661
    16621662// We keep statsFree so that we can identify statistics pointers from the memblock
    1663 static void statsFree(psStats *newStruct)
     1663static void statsFree(psStats *stats)
    16641664{
    16651665    // There are non dynamic allocated items
     1666    return;
    16661667}
    16671668
     
    16691670    psStatsAlloc(): This routine must create a new psStats data structure.
    16701671*****************************************************************************/
    1671 psStats* psStatsAlloc(psStatsOptions options)
     1672psStats* p_psStatsAlloc(const char *file, unsigned int lineno, const char *func, psStatsOptions options)
    16721673{
    16731674    psTrace(TRACE, 3,"---- %s() begin  ----\n", __func__);
    1674     psStats* newStruct = NULL;
    1675 
    1676     newStruct = (psStats* ) psAlloc(sizeof(psStats));
    1677     psMemSetDeallocator(newStruct, (psFreeFunc)statsFree);
    1678     newStruct->sampleMean = NAN;
    1679     newStruct->sampleMedian = NAN;
    1680     newStruct->sampleStdev = NAN;
    1681     newStruct->sampleUQ = NAN;
    1682     newStruct->sampleLQ = NAN;
    1683     newStruct->robustMedian = NAN;
    1684     newStruct->robustStdev = NAN;
    1685     newStruct->robustUQ = NAN;
    1686     newStruct->robustLQ = NAN;
    1687     newStruct->robustN50 = -1;
    1688     newStruct->fittedMean = NAN;
    1689     newStruct->fittedStdev = NAN;
    1690     newStruct->fittedNfit = -1;
    1691     newStruct->clippedMean = NAN;
    1692     newStruct->clippedStdev = NAN;
    1693     newStruct->clippedNvalues = -1;     // XXX: This is never used
    1694     newStruct->clipSigma = 3.0;
    1695     newStruct->clipIter = 3;
    1696     newStruct->min = NAN;
    1697     newStruct->max = NAN;
    1698     newStruct->binsize = NAN;
    1699     newStruct->nSubsample = 100000;
    1700     newStruct->options = options;
     1675
     1676    psStats *stats = p_psAlloc(file, lineno, func, sizeof(psStats));
     1677    psMemSetDeallocator(stats, (psFreeFunc)statsFree);
     1678    stats->sampleMean = NAN;
     1679    stats->sampleMedian = NAN;
     1680    stats->sampleStdev = NAN;
     1681    stats->sampleUQ = NAN;
     1682    stats->sampleLQ = NAN;
     1683    stats->robustMedian = NAN;
     1684    stats->robustStdev = NAN;
     1685    stats->robustUQ = NAN;
     1686    stats->robustLQ = NAN;
     1687    stats->robustN50 = -1;
     1688    stats->fittedMean = NAN;
     1689    stats->fittedStdev = NAN;
     1690    stats->fittedNfit = -1;
     1691    stats->clippedMean = NAN;
     1692    stats->clippedStdev = NAN;
     1693    stats->clippedNvalues = -1;     // XXX: This is never used
     1694    stats->clipSigma = 3.0;
     1695    stats->clipIter = 3;
     1696    stats->min = NAN;
     1697    stats->max = NAN;
     1698    stats->binsize = NAN;
     1699    stats->nSubsample = 100000;
     1700    stats->options = options;
    17011701
    17021702    psTrace(TRACE, 3, "---- %s() end  ----\n", __func__);
    1703     return (newStruct);
     1703    return stats;
    17041704}
    17051705
Note: See TracChangeset for help on using the changeset viewer.