Changeset 6437 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Feb 16, 2006, 2:56:48 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r6322 r6437 16 16 * use ->min and ->max (PS_STAT_USE_RANGE) 17 17 * 18 * @version $Revision: 1.16 7$ $Name: not supported by cvs2svn $19 * @date $Date: 2006-02- 03 22:05:22$18 * @version $Revision: 1.168 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2006-02-17 00:56:48 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 440 440 unmasked element within the specified min/max range). Otherwise, return 441 441 "false". 442 443 XXX: Can you use psVectorCountPixelMask here?444 442 *****************************************************************************/ 445 bool p_psVectorCheckNonEmpty(const psVector* myVector, 446 const psVector* maskVector, 447 psU32 maskVal, 448 psStats* stats) 443 bool p_psVectorCheckNonEmpty( 444 const psVector* myVector, 445 const psVector* maskVector, 446 psU32 maskVal, 447 psStats* stats) 449 448 { 450 449 psTrace(__func__, 4, "---- %s() begin ----\n", __func__); … … 496 495 number of non-masked pixels in the vector that fall within the min/max 497 496 range, if specified. 498 499 XXX: Can you use psVectorCountPixelMask here?500 497 *****************************************************************************/ 501 498 psS32 p_psVectorNValues(const psVector* myVector, … … 644 641 robustHistogram with a Gaussian of width sigma. It returns a psVector of the 645 642 smoothed data. 646 647 XXX: Only PS_TYPE_F32 is supported.648 649 XXX: Write a general routine which smoothes a psVector. This routine should650 call that. Is that possible?651 643 *****************************************************************************/ 652 644 psVector *p_psVectorSmoothHistGaussian( … … 985 977 -1: error 986 978 -2: warning 987 988 XXX: Use static vectors for tmpMask.989 979 *****************************************************************************/ 990 980 psS32 p_psVectorClippedStats(const psVector* myVector, … … 1224 1214 1225 1215 // 1226 // Ensure that the y values are monotonic. 1227 // 1228 // XXX: This routine should probably be rewritten in a more general fashion 1229 // so that the following checks are not necessary. 1216 // Ensure that the y value lies within range of the y values. 1230 1217 // 1231 1218 if (! (((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2])) || … … 1236 1223 } 1237 1224 1225 // 1226 // Ensure that the y values are monotonic. 1227 // 1238 1228 if (((y->data.F64[0] < y->data.F64[1]) && !(y->data.F64[1] <= y->data.F64[2])) || 1239 1229 ((y->data.F64[0] > y->data.F64[1]) && !(y->data.F64[1] >= y->data.F64[2]))) { … … 1289 1279 } else if (binNum == (xVec->n - 2)) { 1290 1280 // XXX: Is this right? 1291 tmpFloat = 0.5 * (xVec->data.F32[binNum] + 1292 xVec->data.F32[binNum + 1]); 1281 tmpFloat = 0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum + 1]); 1293 1282 } 1294 1283 } … … 1677 1666 tmpScalar.data.F32 = totalDataPoints * 0.25f; 1678 1667 if (tmpScalar.data.F32 <= cumulativeRobustHistogram->nums->data.F32[0]) { 1679 // XXX: Special case where its in first bin. Must code last bin.1668 // Special case where its in first bin. The last bin should be handled automatically. 1680 1669 binLo25 = 0; 1681 1670 } else { … … 1684 1673 tmpScalar.data.F32 = totalDataPoints * 0.75f; 1685 1674 if (tmpScalar.data.F32 <= cumulativeRobustHistogram->nums->data.F32[0]) { 1686 // XXX: Special case where its in first bin. Must code last bin.1675 // Special case where its in first bin. The last bin should be handled automatically. 1687 1676 binHi25 = 0; 1688 1677 } else { … … 1704 1693 // Interpolate to find these two positions exactly: these are the upper 1705 1694 // and lower quartile positions. 1706 // XXX: Check for errors.1707 1695 // 1708 1696 psF32 binLo25F32 = fitQuadraticSearchForYThenReturnX( … … 1711 1699 binLo25, 1712 1700 totalDataPoints * 0.25f); 1701 1713 1702 psF32 binHi25F32 = fitQuadraticSearchForYThenReturnX( 1714 1703 *(psVector* *)&cumulativeRobustHistogram->bounds, … … 1716 1705 binHi25, 1717 1706 totalDataPoints * 0.75f); 1707 1708 if (isnan(binLo25F32) || isnan(binHi25F32)) { 1709 psError(PS_ERR_UNKNOWN, false, "could not determine the robustUQ: fitQuadraticSearchForYThenReturnX() returned a NAN.\n"); 1710 psFree(tmpStatsMinMax); 1711 psFree(robustHistogram); 1712 psFree(cumulativeRobustHistogram); 1713 psFree(tmpMaskVec); 1714 psTrace(__func__, 4, "---- %s(1) end ----\n", __func__); 1715 return(1); 1716 } 1717 1718 1718 stats->robustLQ = binLo25F32; 1719 1719 stats->robustUQ = binHi25F32; 1720 1720 psTrace(__func__, 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n", binLo25F32, binHi25F32); 1721 1722 1721 psS32 N50 = 0; 1723 1722 for (psS32 i = 0 ; i < myVector->n ; i++) { … … 1863 1862 } 1864 1863 1865 // XXX: Use the min/max routines for this 1866 psF32 minY = FLT_MAX; 1867 psF32 maxY = -FLT_MAX; 1868 for (psS32 i = 0 ; i < y->n ; i++) { 1869 if (y->data.F32[i] > maxY) { 1870 maxY = y->data.F32[i]; 1871 } 1872 if (y->data.F32[i] < minY) { 1873 minY = y->data.F32[i]; 1874 } 1875 } 1864 rc = p_psVectorMin(y, NULL, 0, tmpStatsMinMax); 1865 rc|= p_psVectorMax(y, NULL, 0, tmpStatsMinMax); 1866 if ((rc != 0) || isnan(tmpStatsMinMax->min) || isnan(tmpStatsMinMax->max)) { 1867 psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n"); 1868 psFree(tmpMaskVec); 1869 psFree(robustHistogram); 1870 psFree(cumulativeRobustHistogram); 1871 psFree(tmpStatsMinMax); 1872 psTrace(__func__, 4, "---- %s(1) end ----\n", __func__); 1873 return(1); 1874 } 1875 1876 1876 // 1877 1877 // Normalize y to [0.0:1.0] (since the psMinimizeLMChi2Gauss1D() functions is [0.0:1.0]) … … 1879 1879 // 1880 1880 for (psS32 i = 0 ; i < y->n ; i++) { 1881 y->data.F32[i]= (y->data.F32[i] - minY) / (maxY - minY);1881 y->data.F32[i]= (y->data.F32[i] - tmpStatsMinMax->min) / (tmpStatsMinMax->max - tmpStatsMinMax->min); 1882 1882 } 1883 1883 … … 2295 2295 } 2296 2296 } else { 2297 // XXX:This if-statement really shouldn't be necessary.2297 // This if-statement really shouldn't be necessary. 2298 2298 // However, due to numerical lack of precision, we 2299 2299 // occasionally produce a binNum outside the range. … … 2435 2435 XXX: Should we free stats if the asserts fail? 2436 2436 *****************************************************************************/ 2437 psStats* psVectorStats(psStats* stats, 2438 const psVector* in, 2439 const psVector* errors, 2440 const psVector* mask, 2441 psMaskType maskVal) 2437 psStats* psVectorStats( 2438 psStats* stats, 2439 const psVector* in, 2440 const psVector* errors, 2441 const psVector* mask, 2442 psMaskType maskVal) 2442 2443 { 2443 2444 psTrace(__func__, 3,"---- %s() begin ----\n", __func__);
Note:
See TracChangeset
for help on using the changeset viewer.
