IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2007, 5:08:17 PM (19 years ago)
Author:
Paul Price
Message:

Fixing compilation problems following change to histogram API.

File:
1 edited

Legend:

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

    r11686 r11760  
    1313 * use ->min and ->max (PS_STAT_USE_RANGE)
    1414 *
    15  *  @version $Revision: 1.200 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-02-07 23:52:54 $
     15 *  @version $Revision: 1.201 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-02-13 03:08:17 $
    1717 *
    1818 *  Copyright 2006 IfA, University of Hawaii
     
    8787/******************************************************************************
    8888MISC PRIVATE STATISTICAL FUNCTIONS
    89  
     89
    9090NOTE: it is assumed that any call to these statistical functions will have
    9191been preceded by a call to the psVectorStats() function.  Various sanity tests
    9292will only be performed in psVectorStats().
    93  
     93
    9494For many of these private stats routines, it is possible that there are no acceptable elements
    9595in the input vector (if no elements lie within range, or there are no unmasked elements, or the
     
    106106mean of the input vector.  If there was a problem with the mean calculation,
    107107this routine sets stats->sampleMean to NAN.
    108  
     108
    109109using the method below, with a single loop for various options costs only a small amount and is
    110110much easier to debug. running 10000 tests of 1000 point vectors for the two methods gives:
    111  
     111
    112112                     separate    single          w/errors
    113113(mask: 0, range: 0): 0.067 sec  0.073 sec (10%)  0.072 sec
     
    115115(mask: 0, range: 0): 0.136 sec  0.162 sec (20%)  0.170 sec
    116116(mask: 1, range: 0): 0.177 sec  0.181 sec ( 2%)  0.198 sec
    117  
     117
    118118(effect of errors not tested)
    119  
     119
    120120To optmize this, use a macro and ifdef in or out the three states (errors, mask, range)
    121121*****************************************************************************/
     
    320320Returns
    321321    NULL
    322  
     322
    323323using the method below, with a single loop for various options costs only a small amount and is
    324324much easier to debug. running 10000 tests of 1000 point vectors for the two methods gives:
    325  
     325
    326326                     single
    327327(mask: 0, range: 0): 0.193 sec
     
    329329(mask: 0, range: 0): 0.349 sec
    330330(mask: 1, range: 0): 0.401 sec
    331  
     331
    332332*****************************************************************************/
    333333static bool vectorSampleStdev(const psVector* myVector,
     
    408408vectorClippedStats(myVector, errors, maskInput, maskValInput, stats): calculates the
    409409clipped stats (mean or stdev) of the input vector.
    410  
     410
    411411Inputs
    412412    myVector
     
    557557vectorRobustStats(myVector, maskInput, maskValInput, stats): This is the new
    558558version of the robust stats routine.
    559  
     559
    560560XXX: MUST DO: If the errors in the input values are known, then the same
    561561approach is used, except that the histograms become probability density
     
    567567each input value contributes constant area. Then the robust median and
    568568standard deviation are estimated in the same manner as above.
    569  
     569
    570570XXX: Check for errors in psLib routines that we call.
    571  
     571
    572572XXX: Review and ensure that all memory is free'ed at premature exits.
    573573*****************************************************************************/
     
    666666        histogram = psHistogramAlloc(min, max, numBins);
    667667        // XXXXX we need to consider this step if errors -> variance
    668         histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal);
     668        if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) {
     669            psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for robust statistics.\n");
     670            psFree(histogram);
     671            psFree(statsMinMax);
     672            return false;
     673        }
    669674        if (psTraceGetLevel("psLib.math") >= 8) {
    670675            PS_VECTOR_PRINT_F32(histogram->bounds);
     
    980985
    981986        psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
    982         histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal);
     987        if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) {
     988            psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistics.\n");
     989            psFree(histogram);
     990            psFree(statsMinMax);
     991            return false;
     992        }
    983993        if (psTraceGetLevel("psLib.math") >= 8) {
    984994            PS_VECTOR_PRINT_F32(histogram->nums);
     
    11741184
    11751185        psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
    1176         histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal);
     1186        if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) {
     1187            psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistcs v2.\n");
     1188            psFree(histogram);
     1189            psFree(statsMinMax);
     1190            return false;
     1191        }
    11771192        if (psTraceGetLevel("psLib.math") >= 8) {
    11781193            PS_VECTOR_PRINT_F32(histogram->nums);
     
    13821397
    13831398        psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
    1384         histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal);
     1399        if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) {
     1400            psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistics v3.\n");
     1401            psFree(histogram);
     1402            psFree(statsMinMax);
     1403            return false;
     1404        }
    13851405        if (psTraceGetLevel("psLib.math") >= 8) {
    13861406            PS_VECTOR_PRINT_F32(histogram->nums);
     
    15941614robustHistogram with a Gaussian of width sigma.  It returns a psVector of the
    15951615smoothed data.
    1596  
     1616
    15971617XXX this function is unused
    15981618*****************************************************************************/
     
    17531773function which calls the above private stats functions based on what bits
    17541774were set in stats->options.
    1755  
     1775
    17561776Inputs
    17571777    in
     
    17611781Returns
    17621782    The stats structure.
    1763  
     1783
    17641784XXX: Should we free stats if the asserts fail? NO; we don't own it (RHL).
    17651785*****************************************************************************/
     
    21072127then determines for what value x does that quadratic f(x) = yVal (the input
    21082128parameter).
    2109  
     2129
    21102130*****************************************************************************/
    21112131static psF32 fitQuadraticSearchForYThenReturnX(const psVector *xVec,
Note: See TracChangeset for help on using the changeset viewer.