Changeset 2204 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2197 r2204 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.6 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-2 6 21:24:43$11 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 00:57:31 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 51 51 52 52 void p_psVectorRobustStats(const psVector* restrict myVector, 53 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats);53 const psVector* restrict maskVector, psU32 maskVal, psStats* stats); 54 54 55 55 … … 75 75 /*****************************************************************************/ 76 76 77 bool p_psGetStatValue(const psStats* stats, double *value)77 psBool p_psGetStatValue(const psStats* stats, double *value) 78 78 { 79 79 … … 134 134 *****************************************************************************/ 135 135 136 void p_psVectorPrint(psVector* myVector, psVector* maskVector, unsigned intmaskVal, psStats* stats)137 { 138 inti = 0; // Loop index variable.136 void p_psVectorPrint(psVector* myVector, psVector* maskVector, psU32 maskVal, psStats* stats) 137 { 138 psS32 i = 0; // Loop index variable. 139 139 140 140 for (i = 0; i < myVector->n; i++) { … … 178 178 179 179 void p_psVectorSampleMean(const psVector* restrict myVector, 180 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)181 { 182 inti = 0; // Loop index variable180 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 181 { 182 psS32 i = 0; // Loop index variable 183 183 float mean = 0.0; // The mean 184 intcount = 0; // # of points in this mean?184 psS32 count = 0; // # of points in this mean? 185 185 float rangeMin = 0.0; // Exclude data below this 186 186 float rangeMax = 0.0; // Exclude date above this … … 242 242 *****************************************************************************/ 243 243 void p_psVectorMax(const psVector* restrict myVector, 244 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)245 { 246 inti = 0; // Loop index variable244 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 245 { 246 psS32 i = 0; // Loop index variable 247 247 float max = -MY_MAX_FLOAT; // The calculated maximum 248 248 float rangeMin = 0.0; // Exclude data below this … … 303 303 *****************************************************************************/ 304 304 void p_psVectorMin(const psVector* restrict myVector, 305 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)306 { 307 inti = 0; // Loop index variable305 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 306 { 307 psS32 i = 0; // Loop index variable 308 308 float min = MY_MAX_FLOAT; // The calculated maximum 309 309 float rangeMin = 0.0; // Exclude data below this … … 363 363 NULL 364 364 *****************************************************************************/ 365 intp_psVectorNValues(const psVector* restrict myVector,366 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)367 { 368 inti = 0; // Loop index variable369 intnumData = 0; // The number of data points365 psS32 p_psVectorNValues(const psVector* restrict myVector, 366 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 367 { 368 psS32 i = 0; // Loop index variable 369 psS32 numData = 0; // The number of data points 370 370 float rangeMin = 0.0; // Exclude data below this 371 371 float rangeMax = 0.0; // Exclude date above this … … 414 414 *****************************************************************************/ 415 415 void p_psVectorSampleMedian(const psVector* restrict myVector, 416 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)416 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 417 417 { 418 418 psVector* unsortedVector = NULL; // Temporary vector 419 419 psVector* sortedVector = NULL; // Temporary vector 420 inti = 0; // Loop index variable421 intcount = 0; // # of points in this mean?422 intnValues = 0; // # of points in vector420 psS32 i = 0; // Loop index variable 421 psS32 count = 0; // # of points in this mean? 422 psS32 nValues = 0; // # of points in vector 423 423 float rangeMin = 0.0; // Exclude data below this 424 424 float rangeMax = 0.0; // Exclude date above this … … 497 497 float sigma) 498 498 { 499 inti = 0; // Loop index variable500 intj = 0; // Loop index variable499 psS32 i = 0; // Loop index variable 500 psS32 j = 0; // Loop index variable 501 501 float iMid; 502 502 float jMid; 503 intnumBins = robustHistogram->nums->n;504 intnumBounds = robustHistogram->bounds->n;503 psS32 numBins = robustHistogram->nums->n; 504 psS32 numBounds = robustHistogram->bounds->n; 505 505 psVector* smooth = psVectorAlloc(numBins, PS_TYPE_F32); 506 intjMin = 0;507 intjMax = 0;506 psS32 jMin = 0; 507 psS32 jMax = 0; 508 508 float firstBound = robustHistogram->bounds->data.F32[0]; 509 509 float lastBound = robustHistogram->bounds->data.F32[numBounds-1]; … … 566 566 *****************************************************************************/ 567 567 void p_psVectorSampleQuartiles(const psVector* restrict myVector, 568 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)568 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 569 569 { 570 570 psVector* unsortedVector = NULL; // Temporary vector 571 571 psVector* sortedVector = NULL; // Temporary vector 572 inti = 0; // Loop index variable573 intcount = 0; // # of points in this mean?574 intnValues = 0; // # data points572 psS32 i = 0; // Loop index variable 573 psS32 count = 0; // # of points in this mean? 574 psS32 nValues = 0; // # data points 575 575 float rangeMin = 0.0; // Exclude data below this 576 576 float rangeMax = 0.0; // Exclude date above this … … 648 648 *****************************************************************************/ 649 649 void p_psVectorSampleStdev(const psVector* restrict myVector, 650 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)651 { 652 inti = 0; // Loop index variable653 intcountInt = 0; // # of data points being used650 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 651 { 652 psS32 i = 0; // Loop index variable 653 psS32 countInt = 0; // # of data points being used 654 654 float countFloat = 0.0; // # of data points being used 655 655 float mean = 0.0; // The mean … … 733 733 *****************************************************************************/ 734 734 void p_psVectorClippedStats(const psVector* restrict myVector, 735 const psVector* restrict maskVector, unsigned intmaskVal, psStats* stats)736 { 737 inti = 0; // Loop index variable738 intj = 0; // Loop index variable735 const psVector* restrict maskVector, psU32 maskVal, psStats* stats) 736 { 737 psS32 i = 0; // Loop index variable 738 psS32 j = 0; // Loop index variable 739 739 float clippedMean = 0.0; // self-explanatory 740 740 float clippedStdev = 0.0; // self-explanatory … … 825 825 float min = (float)HUGE; 826 826 float max = (float)-HUGE; 827 inti = 0;827 psS32 i = 0; 828 828 829 829 for (i = 0; i < myData->n; i++) { … … 856 856 float max = (double)-HUGE; 857 857 double range = 0.0; 858 inti = 0;858 psS32 i = 0; 859 859 860 860 for (i = 0; i < myData->n; i++) { … … 914 914 *****************************************************************************/ 915 915 float p_psGaussianDeriv(const psVector* restrict myData, 916 const psVector* restrict myParams, intwhichParam)916 const psVector* restrict myParams, psS32 whichParam) 917 917 { 918 918 float x = myData->data.F32[0]; … … 957 957 *****************************************************************************/ 958 958 float p_psQuadraticDeriv(const psVector* restrict myParams, 959 const psVector* restrict myCoords, intwhichParamDeriv)959 const psVector* restrict myCoords, psS32 whichParamDeriv) 960 960 { 961 961 float x = myCoords->data.F32[0]; … … 989 989 float getThisValue) 990 990 { 991 intnumIterations = 0;991 psS32 numIterations = 0; 992 992 float midpoint = 0.0; 993 993 float oldMidpoint = 1.0; … … 1030 1030 float fitQuadraticSearchForYThenReturnX(psVector *xVec, 1031 1031 psVector *yVec, 1032 intbinNum,1032 psS32 binNum, 1033 1033 float yVal) 1034 1034 { … … 1129 1129 void p_psVectorRobustStats(const psVector* restrict myVector, 1130 1130 const psVector* restrict maskVector, 1131 unsigned intmaskVal,1131 psU32 maskVal, 1132 1132 psStats* stats) 1133 1133 { … … 1135 1135 psVector* robustHistogramVector = NULL; 1136 1136 float binSize = 0.0; // Size of the histogram bins 1137 intLQBinNum = -1; // Bin num for lower quartile1138 intUQBinNum = -1; // Bin num for upper quartile1139 intmedianBinNum = -1;1140 inti = 0; // Loop index variable1141 intmodeBinNum = 0;1137 psS32 LQBinNum = -1; // Bin num for lower quartile 1138 psS32 UQBinNum = -1; // Bin num for upper quartile 1139 psS32 medianBinNum = -1; 1140 psS32 i = 0; // Loop index variable 1141 psS32 modeBinNum = 0; 1142 1142 float modeBinCount = 0.0; 1143 1143 float dL = 0.0; 1144 intnumBins = 0;1144 psS32 numBins = 0; 1145 1145 float myMean = 0.0; 1146 1146 float myStdev = 0.0; … … 1200 1200 // bins, not the binSize. Also, if we get here, we know that 1201 1201 // binSize != 0.0. 1202 numBins = ( int)((stats->max - stats->min) / binSize);1202 numBins = (psS32)((stats->max - stats->min) / binSize); 1203 1203 robustHistogram = psHistogramAlloc(stats->min, stats->max, numBins); 1204 1204 … … 1440 1440 The histogram structure 1441 1441 *****************************************************************************/ 1442 psHistogram* psHistogramAlloc(float lower, float upper, intn)1443 { 1444 inti = 0; // Loop index variable1442 psHistogram* psHistogramAlloc(float lower, float upper, psS32 n) 1443 { 1444 psS32 i = 0; // Loop index variable 1445 1445 psHistogram* newHist = NULL; // The new histogram structure 1446 1446 float binSize = 0.0; // The histogram bin size … … 1500 1500 { 1501 1501 psHistogram* newHist = NULL; // The new histogram structure 1502 inti; // Loop index variable1502 psS32 i; // Loop index variable 1503 1503 1504 1504 // NOTE: Verify that this is the correct action. … … 1565 1565 const psVector* restrict in, 1566 1566 const psVector* restrict mask, 1567 unsigned intmaskVal)1568 { 1569 inti = 0; // Loop index variable1567 psU32 maskVal) 1568 { 1569 psS32 i = 0; // Loop index variable 1570 1570 float binSize = 0.0; // Histogram bin size 1571 intbinNum = 0; // A temporary bin number1572 intnumBins = 0; // The total number of bins1573 inttmp = 0;1571 psS32 binNum = 0; // A temporary bin number 1572 psS32 numBins = 0; // The total number of bins 1573 psS32 tmp = 0; 1574 1574 psScalar tmpScalar; 1575 1575 tmpScalar.type.type = PS_TYPE_F32; 1576 1576 psVector* inF32; 1577 intmustFreeTmp = 1;1577 psS32 mustFreeTmp = 1; 1578 1578 1579 1579 // NOTE: Verify that this is the correct action. … … 1629 1629 if (out->uniform == true) { 1630 1630 binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; 1631 binNum = ( int)((inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize);1631 binNum = (psS32)((inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize); 1632 1632 1633 1633 // NOTE: This next if-statement really shouldn't be necessary. … … 1673 1673 psVector* p_psConvertToF32(psVector* in) 1674 1674 { 1675 inti = 0;1675 psS32 i = 0; 1676 1676 psVector* tmp = NULL; 1677 1677 … … 1724 1724 psVector* in, 1725 1725 psVector* mask, 1726 unsigned intmaskVal)1726 psU32 maskVal) 1727 1727 { 1728 1728 psVector* inF32; 1729 intmustFreeTmp = 1;1729 psS32 mustFreeTmp = 1; 1730 1730 1731 1731 if (in == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.
