Changeset 2217 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Oct 27, 2004, 11:06:30 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2213 r2217 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-27 2 0:11:47$13 *11 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 21:06:30 $ 13 n * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 15 */ … … 39 39 /* DEFINE STATEMENTS */ 40 40 /*****************************************************************************/ 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])) 56 51 /*****************************************************************************/ 57 52 /* TYPE DEFINITIONS */ … … 59 54 psVector* p_psConvertToF32(psVector* in); 60 55 56 void p_psVectorRobustStats(const psVector* restrict myVector, 57 const psVector* restrict maskVector, 58 psU32 maskVal, 59 psStats* stats); 61 60 /*****************************************************************************/ 62 61 /* GLOBAL VARIABLES */ … … 245 244 { 246 245 psS32 i = 0; // Loop index variable 247 float max = - MY_MAX_FLOAT; // The calculated maximum246 float max = -PS_MAX_FLOAT; // The calculated maximum 248 247 float rangeMin = 0.0; // Exclude data below this 249 248 float rangeMax = 0.0; // Exclude date above this … … 306 305 { 307 306 psS32 i = 0; // Loop index variable 308 float min = MY_MAX_FLOAT; // The calculated maximum307 float min = PS_MAX_FLOAT; // The calculated maximum 309 308 float rangeMin = 0.0; // Exclude data below this 310 309 float rangeMax = 0.0; // Exclude date above this … … 493 492 robustHistogram with a Gaussian of width sigma. 494 493 *****************************************************************************/ 495 #define GAUSS_WIDTH_OTHER 5.0496 494 psVector* p_psVectorSmoothHistGaussian(psHistogram* robustHistogram, 497 495 float sigma) … … 521 519 // warnings? 522 520 523 x.data.F32 = iMid - ( GAUSS_WIDTH * sigma);521 x.data.F32 = iMid - (PS_GAUSS_WIDTH * sigma); 524 522 if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) { 525 523 jMin = p_psVectorBinDisect(robustHistogram->bounds, &x); … … 531 529 } 532 530 533 x.data.F32 = iMid + ( GAUSS_WIDTH * sigma);531 x.data.F32 = iMid + (PS_GAUSS_WIDTH * sigma); 534 532 if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) { 535 533 jMax = p_psVectorBinDisect(robustHistogram->bounds, &x); … … 744 742 745 743 // 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))) { 747 745 psAbort(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter); 748 746 } 749 747 // 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))) { 751 749 psAbort(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma); 752 750 } … … 996 994 // printf("p_ps1DPolyMedian(%f, %f, %f) \n", rangeLow, rangeHigh, getThisValue); 997 995 998 while (numIterations < MAX_ITERATIONS) {996 while (numIterations < PS_POLY_MEDIAN_MAX_ITERATIONS) { 999 997 midpoint = (rangeHigh + rangeLow) / 2.0; 1000 998 if (fabs(midpoint - oldMidpoint) <= FLT_EPSILON) { … … 1099 1097 return(tmpFloat); 1100 1098 } 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]))1104 1099 1105 1100 /******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
