IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 23, 2004, 2:05:54 PM (22 years ago)
Author:
gusciora
Message:

Added -Wall to Makefile.globals, and fixed resultant compile errors.

File:
1 edited

Legend:

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

    r2406 r2411  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-23 19:35:30 $
     11 *  @version $Revision: 1.99 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-24 00:05:54 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    128128NOTE: it is assumed that any call to these statistical functions will have
    129129been preceded by a call to the psVectorStats() function.  Various sanity tests
    130 will only be performed in psVectorStats().
    131  
    132 XXX: Should we perform the sanity checks in each routine anyway?
     130will only be performed in psVectorStats().  Should we perform the sanity
     131checks in each routine anyway?
    133132 
    134133XXX: For many of these private stats routines, what should be done if there
    135 are now acceptable elements in the input vector (if no elements lie within
     134are no acceptable elements in the input vector (if no elements lie within
    136135range, or there are no unmasked elements, or the input vector is NULL)?
    137136Currently we set the value to NAN.
     
    931930
    932931/*****************************************************************************
    933 psNormalizeVectorRange##TYPE(myData, low, high): this is a private function which
    934 normalizes the elements of a vector to a range between low and high.
    935  
    936 XXX: Should we make the arguments psScalars?
    937  
    938 XXX: Should we make the arguments PS_TYPE_F64?
     932These macros and functions define the following functions:
     933 
     934    p_psNormalizeVectorRange(myData, low, high)
     935 
     936That assumes that the low/high arguments are PS_TYPE_F64; the vector myData
     937can be of any type.  Arguments low/high will be converted to the appropriate
     938type and one of the type-specific functions below will be called:
     939 
     940    p_psNormalizeVectorRangeU8(myData, low, high)
     941    p_psNormalizeVectorRangeU16(myData, low, high)
     942    p_psNormalizeVectorRangeU32(myData, low, high)
     943    p_psNormalizeVectorRangeU64(myData, low, high)
     944    p_psNormalizeVectorRangeS8(myData, low, high)
     945    p_psNormalizeVectorRangeS16(myData, low, high)
     946    p_psNormalizeVectorRangeS32(myData, low, high)
     947    p_psNormalizeVectorRangeS64(myData, low, high)
     948    p_psNormalizeVectorRangeF32(myData, low, high)
     949    p_psNormalizeVectorRangeF64(myData, low, high)
    939950 *****************************************************************************/
    940951#define PS_FUNC_MACRO_NORMALIZE_VECTOR_RANGE(TYPE) \
     
    984995PS_FUNC_MACRO_NORMALIZE_VECTOR_RANGE(F64)
    985996
     997void p_psNormalizeVectorRange(psVector* myData,
     998                              psF64 outLow,
     999                              psF64 outHigh)
     1000{
     1001    switch (myData->type.type) {
     1002    case PS_TYPE_U8:
     1003        p_psNormalizeVectorRangeU8(myData, (psU8) outLow, (psU8) outHigh);
     1004        break;
     1005    case PS_TYPE_U16:
     1006        p_psNormalizeVectorRangeU16(myData, (psU16) outLow, (psU16) outHigh);
     1007        break;
     1008    case PS_TYPE_U32:
     1009        p_psNormalizeVectorRangeU32(myData, (psU32) outLow, (psU32) outHigh);
     1010        break;
     1011    case PS_TYPE_U64:
     1012        p_psNormalizeVectorRangeU64(myData, (psU64) outLow, (psU64) outHigh);
     1013        break;
     1014    case PS_TYPE_S8:
     1015        p_psNormalizeVectorRangeS8(myData, (psS8) outLow, (psS8) outHigh);
     1016        break;
     1017    case PS_TYPE_S16:
     1018        p_psNormalizeVectorRangeS16(myData, (psS16) outLow, (psS16) outHigh);
     1019        break;
     1020    case PS_TYPE_S32:
     1021        p_psNormalizeVectorRangeS32(myData, (psS32) outLow, (psS32) outHigh);
     1022        break;
     1023    case PS_TYPE_S64:
     1024        p_psNormalizeVectorRangeS64(myData, (psS64) outLow, (psS64) outHigh);
     1025        break;
     1026    case PS_TYPE_F32:
     1027        p_psNormalizeVectorRangeF32(myData, (psF32) outLow, (psF32) outHigh);
     1028        break;
     1029    case PS_TYPE_F64:
     1030        p_psNormalizeVectorRangeF64(myData, (psF64) outLow, (psF64) outHigh);
     1031        break;
     1032    case PS_TYPE_C32:
     1033    case PS_TYPE_C64:
     1034    default:
     1035        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     1036                "Unallowable operation: %s has incorrect type.",
     1037                myData);
     1038        break;
     1039    }
     1040}
     1041
    9861042/******************************************************************************
    9871043p_ps1DPolyMedian(myPoly, rangeLow, rangeHigh, midpoint): This routine takes
     
    10531109 
    10541110XXX: After you fit the polynomial, solve for X analytically.
    1055  
    1056 XXX: Check for errors in psLib routines that we call.
    10571111*****************************************************************************/
    10581112float fitQuadraticSearchForYThenReturnX(psVector *xVec,
     
    11041158        // polynomial, looking for the value x such that f(x) = yVal
    11051159        tmpFloat = p_ps1DPolyMedian(myPoly, x->data.F64[0], x->data.F64[2], yVal);
     1160        if (isnan(tmpFloat)) {
     1161            psError(PS_ERR_UNEXPECTED_NULL,
     1162                    false,
     1163                    PS_ERRORTEXT_psStats_STATS_FIT_QUADRATIC_POLY_MEDIAN);
     1164            return(NAN);
     1165        }
    11061166
    11071167    } else {
     
    11351195    PS_STAT_ROBUST_QUARTILE
    11361196I have included all that computation in a single function, as opposed to
    1137 breaking it across several functions for one primary reason:  they all
    1138 require the same basic initial processing steps (calculate the histogram,
    1139 etc.)  however there is no currently defined means, in the SDRS, to specify
    1140 this computation as a separate step.  If the above robust stat measures were
    1141 calcualted in separate functiosn, then much of the initial processing would
    1142 be duplicated.
     1197breaking it across several functions for one primary reason:  they all require
     1198the same basic initial processing steps (calculate the histogram, etc.).
    11431199 
    11441200Inputs
     
    11851241    // by computing the clipped standard deviation of the vector, and dividing
    11861242    // that by 10.0;
    1187     p_psVectorClippedStats(myVector, maskVector, maskVal, tmpStats);
     1243    int rc = p_psVectorClippedStats(myVector, maskVector, maskVal, tmpStats);
     1244    if (rc != 0) {
     1245        psError(PS_ERR_UNEXPECTED_NULL,
     1246                false,
     1247                PS_ERRORTEXT_psStats_ROBUST_STATS_CLIPPED_STATS);
     1248        return(1);
     1249    }
    11881250    binSize = tmpStats->clippedStdev / 10.0f;
    11891251
     
    12131275        return(0);
    12141276    }
     1277
    12151278    // Determine minimum and maximum values in the data vector.
    12161279    if (isnan(stats->min)) {
     
    12211284        }
    12221285    }
    1223 
    1224 
    12251286    if (isnan(stats->max)) {
    1226         if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {}
     1287        if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {
     1288            psLogMsg(__func__, PS_LOG_WARN,
     1289                     "WARNING: p_psVectorMin(): p_psVectorMax() reported a NAN mean.\n");
     1290            return(1);
     1291        }
    12271292    }
    12281293
     
    15941659
    15951660    psS32 i = 0;                  // Loop index variable
    1596     float binSize = 0.0;        // Histogram bin size
     1661    float binSize = 0.0;          // Histogram bin size
    15971662    psS32 binNum = 0;             // A temporary bin number
    15981663    psS32 numBins = 0;            // The total number of bins
     
    16081673    }
    16091674
    1610 
    16111675    numBins = out->nums->n;
    16121676    for (i = 0; i < inF32->n; i++) {
    16131677        // Check if this pixel is masked, and if so, skip it.
    1614         if ((mask == NULL) || ((mask != NULL) && (!(mask->data.U8[i] & maskVal)))) {
    1615             // Check if this pixel is below the minimum value, and if so
    1616             // count it, then skip it.
     1678        if ((mask == NULL) ||
     1679                ((mask != NULL) && (!(mask->data.U8[i] & maskVal)))) {
    16171680            if (inF32->data.F32[i] < out->bounds->data.F32[0]) {
     1681                // If this pixel is below minimum value, count it, then skip.
    16181682                out->minNum++;
    1619                 // Check if this pixel is above the maximum value, and if so
    1620                 // count it, then skip it.
    16211683            } else if (inF32->data.F32[i] > out->bounds->data.F32[numBins]) {
     1684                // If this pixel is above maximum value, count it, then skip.
    16221685                out->maxNum++;
    16231686            } else {
     
    16291692
    16301693                    // XXX: This if-statement really shouldn't be necessary.
    1631                     // However, due to numerical lack of precision, we occasionally
    1632                     // produce a binNum outside the range of bins.
     1694                    // However, due to numerical lack of precision, we
     1695                    // occasionally produce a binNum outside the range.
    16331696                    if (binNum >= out->nums->n) {
    16341697                        binNum = out->nums->n - 1;
     
    16371700                    (out->nums->data.U32[binNum])++;
    16381701
    1639                     // If this is a non-uniform histogram, determining the correct
    1640                     // bin number requires a bit more work.
    16411702                } else {
     1703                    // If this is a non-uniform histogram, determining the
     1704                    // correct bin number requires a bit more work.
    16421705                    tmpScalar.data.F32 = inF32->data.F32[i];
    16431706                    tmp = p_psVectorBinDisect(out->bounds, &tmpScalar);
    16441707                    if (tmp < 0) {
    1645                         // XXX: Generate warning message
     1708                        psLogMsg(__func__, PS_LOG_WARN,
     1709                                 "WARNING: psVectorHistogram(): element outside histogram bounds.\n");
    16461710                    } else {
    16471711                        (out->nums->data.U32[tmp])++;
     
    16661730everything and put type support in the various stat functions.
    16671731 
    1668 XXX: Should the default data type be F64?  Since we are buying Athlons...
     1732XXX: Should the default data type be F64?  Since we are buying Opterons...
    16691733 *****************************************************************************/
    16701734psVector* p_psConvertToF32(psVector* in)
     
    17441808    // ************************************************************************
    17451809    if (stats->options & PS_STAT_SAMPLE_MEAN) {
    1746         p_psVectorSampleMean(inF32, mask, maskVal, stats);
     1810        if (0 != p_psVectorSampleMean(inF32, mask, maskVal, stats)) {
     1811            psLogMsg(__func__, PS_LOG_WARN,
     1812                     "WARNING: psVectorStats(): p_psVectorSampleMean() returned an error.\n");
     1813        }
    17471814    }
    17481815    // ************************************************************************
    17491816    if (stats->options & PS_STAT_SAMPLE_MEDIAN) {
    1750         p_psVectorSampleMedian(inF32, mask, maskVal, stats);
     1817        if (false == p_psVectorSampleMedian(inF32, mask, maskVal, stats)) {
     1818            psLogMsg(__func__, PS_LOG_WARN,
     1819                     "WARNING: psVectorStats(): p_psVectorSampleMedian() returned an error.\n");
     1820        }
    17511821    }
    17521822    // ************************************************************************
    17531823    if (stats->options & PS_STAT_SAMPLE_STDEV) {
    1754         p_psVectorSampleMean(inF32, mask, maskVal, stats);
     1824        if (0 != p_psVectorSampleMean(inF32, mask, maskVal, stats)) {
     1825            psLogMsg(__func__, PS_LOG_WARN,
     1826                     "WARNING: psVectorStats(): p_psVectorSampleMean() returned an error.\n");
     1827        }
    17551828        p_psVectorSampleStdev(inF32, mask, maskVal, stats);
    17561829    }
    17571830    // ************************************************************************
    17581831    if (stats->options & PS_STAT_SAMPLE_QUARTILE) {
    1759         p_psVectorSampleQuartiles(inF32, mask, maskVal, stats);
     1832        if (false == p_psVectorSampleQuartiles(inF32, mask, maskVal, stats)) {
     1833            psLogMsg(__func__, PS_LOG_WARN,
     1834                     "WARNING: psVectorStats(): p_psVectorSampleQuartiles() returned an error.\n");
     1835        }
    17601836    }
    17611837    // Since the various robust stats quantities share much computation, they
     
    17651841            (stats->options & PS_STAT_ROBUST_MEDIAN) ||
    17661842            (stats->options & PS_STAT_ROBUST_MODE) ||
    1767             (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
     1843            (stats->options & PS_STAT_ROBUST_STDEV) ||
     1844            (stats->options & PS_STAT_ROBUST_QUARTILE)) {
    17681845        if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) {
    17691846            psError(PS_ERR_UNKNOWN, false,
Note: See TracChangeset for help on using the changeset viewer.