Changeset 1440 for trunk/psLib/src/dataManip/psStats.c
- Timestamp:
- Aug 9, 2004, 1:34:58 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psStats.c (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psStats.c
r1407 r1440 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.5 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-0 7 00:06:06$12 * @version $Revision: 1.53 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-09 23:34:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 54 54 #define MAX_ITERATIONS 10 55 55 56 void p_psVectorRobustStats(const psVector * restrict myVector,57 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats);56 void p_psVectorRobustStats(const psVector* restrict myVector, 57 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats); 58 58 59 59 /** Preprocessor macro to generate error on an incorrect type */ … … 116 116 /*****************************************************************************/ 117 117 118 bool p_psGetStatValue(const psStats * stats, double *value)118 bool p_psGetStatValue(const psStats* stats, double *value) 119 119 { 120 120 … … 175 175 *****************************************************************************/ 176 176 177 void p_psVectorPrint(psVector * myVector, psVector * maskVector, unsigned int maskVal, psStats* stats)177 void p_psVectorPrint(psVector* myVector, psVector* maskVector, unsigned int maskVal, psStats* stats) 178 178 { 179 179 int i = 0; // Loop index variable. … … 218 218 *****************************************************************************/ 219 219 220 void p_psVectorSampleMean(const psVector * restrict myVector,221 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)220 void p_psVectorSampleMean(const psVector* restrict myVector, 221 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 222 222 { 223 223 int i = 0; // Loop index variable … … 282 282 NULL 283 283 *****************************************************************************/ 284 void p_psVectorMax(const psVector * restrict myVector,285 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)284 void p_psVectorMax(const psVector* restrict myVector, 285 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 286 286 { 287 287 int i = 0; // Loop index variable … … 343 343 NULL 344 344 *****************************************************************************/ 345 void p_psVectorMin(const psVector * restrict myVector,346 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)345 void p_psVectorMin(const psVector* restrict myVector, 346 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 347 347 { 348 348 int i = 0; // Loop index variable … … 404 404 NULL 405 405 *****************************************************************************/ 406 int p_psVectorNValues(const psVector * restrict myVector,407 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)406 int p_psVectorNValues(const psVector* restrict myVector, 407 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 408 408 { 409 409 int i = 0; // Loop index variable … … 456 456 NULL 457 457 *****************************************************************************/ 458 void p_psVectorSampleMedian(const psVector * restrict myVector,459 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)460 { 461 psVector *unsortedVector = NULL; // Temporary vector462 psVector *sortedVector = NULL; // Temporary vector458 void p_psVectorSampleMedian(const psVector* restrict myVector, 459 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 460 { 461 psVector* unsortedVector = NULL; // Temporary vector 462 psVector* sortedVector = NULL; // Temporary vector 463 463 int i = 0; // Loop index variable 464 464 int count = 0; // # of points in this mean? … … 565 565 XXX: use a static variable for gaussianCoefs[] and compute them once. 566 566 *****************************************************************************/ 567 psVector *p_psVectorsmoothHistGaussian(psHistogram* robustHistogram, float sigma)567 psVector* p_psVectorsmoothHistGaussian(psHistogram* robustHistogram, float sigma) 568 568 { 569 569 int i = 0; // Loop index variable … … 572 572 float expo = 0.0; // Temporary variable 573 573 float gaussianCoefs[1 + (2 * GAUSS_WIDTH)]; // The Gaussian Coefficients 574 psVector *smooth = psVectorAlloc(robustHistogram->nums->n, PS_TYPE_F32);574 psVector* smooth = psVectorAlloc(robustHistogram->nums->n, PS_TYPE_F32); 575 575 576 576 for (i = 0; i < (1 + (2 * GAUSS_WIDTH)); i++) { … … 628 628 NULL 629 629 *****************************************************************************/ 630 void p_psVectorSampleQuartiles(const psVector * restrict myVector,631 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)632 { 633 psVector *unsortedVector = NULL; // Temporary vector634 psVector *sortedVector = NULL; // Temporary vector630 void p_psVectorSampleQuartiles(const psVector* restrict myVector, 631 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 632 { 633 psVector* unsortedVector = NULL; // Temporary vector 634 psVector* sortedVector = NULL; // Temporary vector 635 635 int i = 0; // Loop index variable 636 636 int count = 0; // # of points in this mean? … … 710 710 711 711 *****************************************************************************/ 712 void p_psVectorSampleStdev(const psVector * restrict myVector,713 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)712 void p_psVectorSampleStdev(const psVector* restrict myVector, 713 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 714 714 { 715 715 int i = 0; // Loop index variable … … 795 795 NULL 796 796 *****************************************************************************/ 797 void p_psVectorClippedStats(const psVector * restrict myVector,798 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)797 void p_psVectorClippedStats(const psVector* restrict myVector, 798 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 799 799 { 800 800 int i = 0; // Loop index variable … … 804 804 float oldStanMean = 0.0; // Temporary variable 805 805 float oldStanStdev = 0.0; // Temporary variable 806 psVector *tmpMask = NULL; // Temporary vector806 psVector* tmpMask = NULL; // Temporary vector 807 807 808 808 // Endure that stats->clipIter is within the proper range. … … 884 884 elements of a vector to a range between 0.0 and 1.0. 885 885 *****************************************************************************/ 886 void p_psNormalizeVector(psVector * myData)886 void p_psNormalizeVector(psVector* myData) 887 887 { 888 888 float min = (float)HUGE; … … 911 911 specified data point. 912 912 *****************************************************************************/ 913 float p_psGaussian(const psVector * restrict myData, const psVector* restrict myParams)913 float p_psGaussian(const psVector* restrict myData, const psVector* restrict myParams) 914 914 { 915 915 float x = myData->data.F32[0]; … … 928 928 calculates the specified partial derivative of the above Gaussian function. 929 929 *****************************************************************************/ 930 float p_psGaussianDeriv(const psVector * restrict myData, const psVector* restrict myParams, int whichParam)930 float p_psGaussianDeriv(const psVector* restrict myData, const psVector* restrict myParams, int whichParam) 931 931 { 932 932 float x = myData->data.F32[0]; … … 954 954 specified data point. 955 955 *****************************************************************************/ 956 float p_psQuadratic(const psVector * restrict myParams, const psVector* restrict myCoords)956 float p_psQuadratic(const psVector* restrict myParams, const psVector* restrict myCoords) 957 957 { 958 958 float x = myCoords->data.F32[0]; … … 970 970 calculates the specified partial derivative of the above quadratic function. 971 971 *****************************************************************************/ 972 float p_psQuadraticDeriv(const psVector * restrict myParams,973 const psVector * restrict myCoords, int whichParamDeriv)972 float p_psQuadraticDeriv(const psVector* restrict myParams, 973 const psVector* restrict myCoords, int whichParamDeriv) 974 974 { 975 975 float x = myCoords->data.F32[0]; … … 996 996 decreasing within that range. 997 997 *****************************************************************************/ 998 float p_ps1DPolyMedian(psPolynomial1D * myPoly, float rangeLow, float rangeHigh, float getThisValue)998 float p_ps1DPolyMedian(psPolynomial1D* myPoly, float rangeLow, float rangeHigh, float getThisValue) 999 999 { 1000 1000 int numIterations = 0; … … 1036 1036 XXX: This function is currently not being used. 1037 1037 *****************************************************************************/ 1038 float p_psFitQuadratic(psHistogram * histogram, psVector* cumulativeSums, int binNum, float fitFloat)1039 { 1040 psVector *x = psVectorAlloc(3, PS_TYPE_F64);1041 psVector *y = psVectorAlloc(3, PS_TYPE_F64);1042 psVector *yErr = psVectorAlloc(3, PS_TYPE_F64);1043 psPolynomial1D *myPoly = psPolynomial1DAlloc(2);1038 float p_psFitQuadratic(psHistogram* histogram, psVector* cumulativeSums, int binNum, float fitFloat) 1039 { 1040 psVector* x = psVectorAlloc(3, PS_TYPE_F64); 1041 psVector* y = psVectorAlloc(3, PS_TYPE_F64); 1042 psVector* yErr = psVectorAlloc(3, PS_TYPE_F64); 1043 psPolynomial1D* myPoly = psPolynomial1DAlloc(2); 1044 1044 1045 1045 if ((binNum > 0) && (binNum < (histogram->nums->n + 1))) { … … 1100 1100 NULL 1101 1101 *****************************************************************************/ 1102 void p_psVectorRobustStats(const psVector * restrict myVector,1103 const psVector * restrict maskVector, unsigned int maskVal, psStats* stats)1104 { 1105 psHistogram *robustHistogram = NULL;1106 psVector *robustHistogramVector = NULL;1102 void p_psVectorRobustStats(const psVector* restrict myVector, 1103 const psVector* restrict maskVector, unsigned int maskVal, psStats* stats) 1104 { 1105 psHistogram* robustHistogram = NULL; 1106 psVector* robustHistogramVector = NULL; 1107 1107 float binSize = 0.0; // Size of the histogram bins 1108 1108 int LQBinNum = -1; // Bin num for lower quartile … … 1113 1113 float dL = 0.0; 1114 1114 int numBins = 0; 1115 psStats *tmpStats = psStatsAlloc(PS_STAT_CLIPPED_STDEV | PS_STAT_CLIPPED_MEAN);1116 1117 // psImage *domain;1118 // psVector *errors;1119 // psVector *data;1120 // psVector *initialGuess;1121 // psVector *theParams;1115 psStats* tmpStats = psStatsAlloc(PS_STAT_CLIPPED_STDEV | PS_STAT_CLIPPED_MEAN); 1116 1117 // psImage* domain; 1118 // psVector* errors; 1119 // psVector* data; 1120 // psVector* initialGuess; 1121 // psVector* theParams; 1122 1122 // float chiSq=0.0; 1123 1123 // float max = -HUGE; … … 1129 1129 float sumSquares = 0.0; 1130 1130 float sumDiffs = 0.0; 1131 psVector *x = psVectorAlloc(3, PS_TYPE_F64);1132 psVector *y = psVectorAlloc(3, PS_TYPE_F64);1133 psVector *yErr = psVectorAlloc(3, PS_TYPE_F64);1134 psPolynomial1D *myPoly = psPolynomial1DAlloc(2);1135 psVector *cumulativeRobustSumsFullRange = NULL;1136 psVector *cumulativeRobustSumsDlRange = NULL;1131 psVector* x = psVectorAlloc(3, PS_TYPE_F64); 1132 psVector* y = psVectorAlloc(3, PS_TYPE_F64); 1133 psVector* yErr = psVectorAlloc(3, PS_TYPE_F64); 1134 psPolynomial1D* myPoly = psPolynomial1DAlloc(2); 1135 psVector* cumulativeRobustSumsFullRange = NULL; 1136 psVector* cumulativeRobustSumsDlRange = NULL; 1137 1137 float sumRobust = 0.0; 1138 1138 float sumN50 = 0.0; … … 1500 1500 /*****************************************************************************/ 1501 1501 1502 static void histogramFree(psHistogram * myHist);1502 static void histogramFree(psHistogram* myHist); 1503 1503 1504 1504 /****************************************************************************** 1505 1505 psStatsAlloc(): This routine must create a new psStats data structure. 1506 1506 *****************************************************************************/ 1507 psStats *psStatsAlloc(psStatsOptions options)1508 { 1509 psStats *newStruct = NULL;1510 1511 newStruct = (psStats *) psAlloc(sizeof(psStats));1507 psStats* psStatsAlloc(psStatsOptions options) 1508 { 1509 psStats* newStruct = NULL; 1510 1511 newStruct = (psStats* ) psAlloc(sizeof(psStats)); 1512 1512 newStruct->sampleMean = NAN; 1513 1513 newStruct->sampleMedian = NAN; … … 1548 1548 The histogram structure 1549 1549 *****************************************************************************/ 1550 psHistogram *psHistogramAlloc(float lower, float upper, int n)1550 psHistogram* psHistogramAlloc(float lower, float upper, int n) 1551 1551 { 1552 1552 int i = 0; // Loop index variable 1553 psHistogram *newHist = NULL; // The new histogram structure1553 psHistogram* newHist = NULL; // The new histogram structure 1554 1554 float binSize = 0.0; // The histogram bin size 1555 1555 … … 1567 1567 // Allocate memory for the new histogram structure. If there are N 1568 1568 // bins, then there are N+1 bounds to those bins. 1569 newHist = (psHistogram *) psAlloc(sizeof(psHistogram));1569 newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); 1570 1570 p_psMemSetDeallocator(newHist, (psFreeFcn) histogramFree); 1571 1571 newHist->bounds = psVectorAlloc(n + 1, PS_TYPE_F32); … … 1605 1605 The histogram structure 1606 1606 *****************************************************************************/ 1607 psHistogram *psHistogramAllocGeneric(const psVector* restrict bounds)1608 { 1609 psHistogram *newHist = NULL; // The new histogram structure1607 psHistogram* psHistogramAllocGeneric(const psVector* restrict bounds) 1608 { 1609 psHistogram* newHist = NULL; // The new histogram structure 1610 1610 int i; // Loop index variable 1611 1611 … … 1626 1626 } 1627 1627 // Allocate memory for the new histogram structure. 1628 newHist = (psHistogram *) psAlloc(sizeof(psHistogram));1628 newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); 1629 1629 p_psMemSetDeallocator(newHist, (psFreeFcn) histogramFree); 1630 1630 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); … … 1650 1650 } 1651 1651 1652 static void histogramFree(psHistogram * myHist)1652 static void histogramFree(psHistogram* myHist) 1653 1653 { 1654 1654 psFree(myHist->bounds); … … 1670 1670 The histogram structure "out". 1671 1671 *****************************************************************************/ 1672 psHistogram *psVectorHistogram(psHistogram* out,1673 const psVector * restrict in,1674 const psVector * restrict mask, unsigned int maskVal)1672 psHistogram* psVectorHistogram(psHistogram* out, 1673 const psVector* restrict in, 1674 const psVector* restrict mask, unsigned int maskVal) 1675 1675 { 1676 1676 int i = 0; // Loop index variable … … 1767 1767 the various stat functions. 1768 1768 *****************************************************************************/ 1769 psVector *p_psConvertToF32(psStats * stats, psVector * in, psVector* mask, unsigned int maskVal)1769 psVector* p_psConvertToF32(psStats* stats, psVector* in, psVector* mask, unsigned int maskVal) 1770 1770 { 1771 1771 int i = 0; 1772 psVector *tmp = NULL;1772 psVector* tmp = NULL; 1773 1773 1774 1774 if (in->type.type == PS_TYPE_S32) { … … 1812 1812 macro-ize everything and add PS_TYPE_U16 and PS_TYPE_F64. 1813 1813 *****************************************************************************/ 1814 psStats *psVectorStats(psStats * stats, psVector * in, psVector* mask, unsigned int maskVal)1815 { 1816 psVector *inF32;1814 psStats* psVectorStats(psStats* stats, psVector* in, psVector* mask, unsigned int maskVal) 1815 { 1816 psVector* inF32; 1817 1817 int mustFreeTmp = 1; 1818 1818
Note:
See TracChangeset
for help on using the changeset viewer.
