IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2004, 11:06:30 AM (22 years ago)
Author:
gusciora
Message:

Added parameter checking to psFunctions.c

File:
1 edited

Legend:

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

    r2213 r2217  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 20:11:47 $
    13  *
     11 *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-27 21:06:30 $
     13n *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1515 */
     
    3939/* DEFINE STATEMENTS                                                         */
    4040/*****************************************************************************/
    41 // will use robust statistical methods.
    42 #define GAUSS_WIDTH 5       // The width of the Gaussian or boxcar smoothing.
    43 #define CLIPPED_NUM_ITER_LB 1
    44 #define CLIPPED_NUM_ITER_UB 10
    45 #define CLIPPED_SIGMA_LB 1.0
    46 #define CLIPPED_SIGMA_UB 10.0
    47 #define true 1
    48 #define false 0
    49 #define MY_MAX_FLOAT HUGE
    50 #define MAX_ITERATIONS 10
    51 
    52 void p_psVectorRobustStats(const psVector* restrict myVector,
    53                            const psVector* restrict maskVector, psU32 maskVal, psStats* stats);
    54 
    55 
     41#define PS_GAUSS_WIDTH 5       // The width of the Gaussian or boxcar smoothing.
     42#define PS_CLIPPED_NUM_ITER_LB 1
     43#define PS_CLIPPED_NUM_ITER_UB 10
     44#define PS_CLIPPED_SIGMA_LB 1.0
     45#define PS_CLIPPED_SIGMA_UB 10.0
     46#define PS_MAX_FLOAT HUGE
     47#define PS_POLY_MEDIAN_MAX_ITERATIONS 10
     48
     49#define PS_BIN_MIDPOINT(HISTOGRAM, BIN_NUM) \
     50(0.5 * (HISTOGRAM->bounds->data.F32[(BIN_NUM)] + HISTOGRAM->bounds->data.F32[(BIN_NUM)+1]))
    5651/*****************************************************************************/
    5752/* TYPE DEFINITIONS                                                          */
     
    5954psVector* p_psConvertToF32(psVector* in);
    6055
     56void p_psVectorRobustStats(const psVector* restrict myVector,
     57                           const psVector* restrict maskVector,
     58                           psU32 maskVal,
     59                           psStats* stats);
    6160/*****************************************************************************/
    6261/* GLOBAL VARIABLES                                                          */
     
    245244{
    246245    psS32 i = 0;                  // Loop index variable
    247     float max = -MY_MAX_FLOAT;  // The calculated maximum
     246    float max = -PS_MAX_FLOAT;  // The calculated maximum
    248247    float rangeMin = 0.0;       // Exclude data below this
    249248    float rangeMax = 0.0;       // Exclude date above this
     
    306305{
    307306    psS32 i = 0;                  // Loop index variable
    308     float min = MY_MAX_FLOAT;   // The calculated maximum
     307    float min = PS_MAX_FLOAT;   // The calculated maximum
    309308    float rangeMin = 0.0;       // Exclude data below this
    310309    float rangeMax = 0.0;       // Exclude date above this
     
    493492robustHistogram with a Gaussian of width sigma.
    494493 *****************************************************************************/
    495 #define GAUSS_WIDTH_OTHER 5.0
    496494psVector* p_psVectorSmoothHistGaussian(psHistogram* robustHistogram,
    497495                                       float sigma)
     
    521519        // warnings?
    522520
    523         x.data.F32 = iMid - (GAUSS_WIDTH * sigma);
     521        x.data.F32 = iMid - (PS_GAUSS_WIDTH * sigma);
    524522        if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    525523            jMin = p_psVectorBinDisect(robustHistogram->bounds, &x);
     
    531529        }
    532530
    533         x.data.F32 = iMid + (GAUSS_WIDTH * sigma);
     531        x.data.F32 = iMid + (PS_GAUSS_WIDTH * sigma);
    534532        if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    535533            jMax = p_psVectorBinDisect(robustHistogram->bounds, &x);
     
    744742
    745743    // Endure that stats->clipIter is within the proper range.
    746     if (!((CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= CLIPPED_NUM_ITER_UB))) {
     744    if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) {
    747745        psAbort(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter);
    748746    }
    749747    // Endure that stats->clipSigma is within the proper range.
    750     if (!((CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= CLIPPED_SIGMA_UB))) {
     748    if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) {
    751749        psAbort(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma);
    752750    }
     
    996994    // printf("p_ps1DPolyMedian(%f, %f, %f) \n", rangeLow, rangeHigh, getThisValue);
    997995
    998     while (numIterations < MAX_ITERATIONS) {
     996    while (numIterations < PS_POLY_MEDIAN_MAX_ITERATIONS) {
    999997        midpoint = (rangeHigh + rangeLow) / 2.0;
    1000998        if (fabs(midpoint - oldMidpoint) <= FLT_EPSILON) {
     
    10991097    return(tmpFloat);
    11001098}
    1101 
    1102 #define PS_BIN_MIDPOINT(HISTOGRAM, BIN_NUM) \
    1103 (0.5 * (HISTOGRAM->bounds->data.F32[(BIN_NUM)] + HISTOGRAM->bounds->data.F32[(BIN_NUM)+1]))
    11041099
    11051100/******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.