Changeset 2788 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Dec 21, 2004, 7:09:32 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (40 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2782 r2788 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-12-22 0 0:54:28$11 * @version $Revision: 1.108 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-12-22 05:09:32 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 /*****************************************************************************/ 71 71 72 psBool p_psGetStatValue(const psStats* stats, double*value)72 psBool p_psGetStatValue(const psStats* stats, psF64 *value) 73 73 { 74 74 … … 145 145 this routine sets stats->sampleMean to NAN. 146 146 *****************************************************************************/ 147 intp_psVectorSampleMean(const psVector* restrict myVector,148 const psVector* restrict errors,149 const psVector* restrict maskVector,150 psU32 maskVal,151 psStats* stats)147 psS32 p_psVectorSampleMean(const psVector* restrict myVector, 148 const psVector* restrict errors, 149 const psVector* restrict maskVector, 150 psU32 maskVal, 151 psStats* stats) 152 152 { 153 153 154 154 psS32 i = 0; // Loop index variable 155 floatmean = 0.0; // The mean155 psF32 mean = 0.0; // The mean 156 156 psS32 count = 0; // # of points in this mean 157 157 … … 171 171 } 172 172 if (count != 0) { 173 mean /= ( float)count;173 mean /= (psF32)count; 174 174 } else { 175 175 mean = NAN; … … 185 185 } 186 186 if (count != 0) { 187 mean /= ( float)count;187 mean /= (psF32)count; 188 188 } else { 189 189 mean = NAN; … … 199 199 } 200 200 if (count != 0) { 201 mean /= ( float)count;201 mean /= (psF32)count; 202 202 } else { 203 203 mean = NAN; … … 207 207 mean += myVector->data.F32[i]; 208 208 } 209 mean /= ( float)myVector->n;209 mean /= (psF32)myVector->n; 210 210 } 211 211 } … … 283 283 this routine sets stats->max to NAN. 284 284 *****************************************************************************/ 285 intp_psVectorMax(const psVector* restrict myVector,286 const psVector* restrict maskVector,287 psU32 maskVal,288 psStats* stats)285 psS32 p_psVectorMax(const psVector* restrict myVector, 286 const psVector* restrict maskVector, 287 psU32 maskVal, 288 psStats* stats) 289 289 { 290 290 psS32 i = 0; // Loop index variable 291 floatmax = -PS_MAX_F32; // The calculated maximum291 psF32 max = -PS_MAX_F32; // The calculated maximum 292 292 psS32 empty = true; // Does this vector have valid elements? 293 293 … … 348 348 this routine sets stats->min to NAN. 349 349 *****************************************************************************/ 350 intp_psVectorMin(const psVector* restrict myVector,351 const psVector* restrict maskVector,352 psU32 maskVal,353 psStats* stats)350 psS32 p_psVectorMin(const psVector* restrict myVector, 351 const psVector* restrict maskVector, 352 psU32 maskVal, 353 psStats* stats) 354 354 { 355 355 psS32 i = 0; // Loop index variable 356 floatmin = PS_MAX_F32; // The calculated maximum356 psF32 min = PS_MAX_F32; // The calculated maximum 357 357 psS32 empty = true; // Does this vector have valid elements? 358 358 … … 612 612 *****************************************************************************/ 613 613 psVector* p_psVectorSmoothHistGaussian(psHistogram* robustHistogram, 614 floatsigma)614 psF32 sigma) 615 615 { 616 616 PS_PTR_CHECK_NULL(robustHistogram, NULL); … … 619 619 psS32 i = 0; // Loop index variable 620 620 psS32 j = 0; // Loop index variable 621 floatiMid;622 floatjMid;621 psF32 iMid; 622 psF32 jMid; 623 623 psS32 numBins = robustHistogram->nums->n; 624 624 psS32 numBounds = robustHistogram->bounds->n; … … 626 626 psS32 jMin = 0; 627 627 psS32 jMax = 0; 628 floatfirstBound = robustHistogram->bounds->data.F32[0];629 floatlastBound = robustHistogram->bounds->data.F32[numBounds-1];628 psF32 firstBound = robustHistogram->bounds->data.F32[0]; 629 psF32 lastBound = robustHistogram->bounds->data.F32[numBounds-1]; 630 630 psScalar x; 631 631 … … 795 795 psS32 i = 0; // Loop index variable 796 796 psS32 countInt = 0; // # of data points being used 797 floatcountFloat = 0.0; // # of data points being used798 floatmean = 0.0; // The mean799 floatdiff = 0.0; // Used in calculating stdev800 floatsumSquares = 0.0; // temporary variable801 floatsumDiffs = 0.0; // temporary variable797 psF32 countFloat = 0.0; // # of data points being used 798 psF32 mean = 0.0; // The mean 799 psF32 diff = 0.0; // Used in calculating stdev 800 psF32 sumSquares = 0.0; // temporary variable 801 psF32 sumDiffs = 0.0; // temporary variable 802 802 803 803 // This procedure requires the mean. If it has not been already … … 865 865 psLogMsg(__func__, PS_LOG_WARN, "WARNING: p_psVectorSampleStdev(): only one valid psVector elements (%d). Setting stats->sampleStdev = 0.0.\n", countInt); 866 866 } else { 867 countFloat = ( float)countInt;867 countFloat = (psF32)countInt; 868 868 stats->sampleStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1)); 869 869 } … … 889 889 psS32 i = 0; // Loop index variable 890 890 psS32 countInt = 0; // # of data points being used 891 floatcountFloat = 0.0; // # of data points being used892 floatmean = 0.0; // The mean893 floatdiff = 0.0; // Used in calculating stdev894 floatsumSquares = 0.0; // temporary variable895 floatsumDiffs = 0.0; // temporary variable891 psF32 countFloat = 0.0; // # of data points being used 892 psF32 mean = 0.0; // The mean 893 psF32 diff = 0.0; // Used in calculating stdev 894 psF32 sumSquares = 0.0; // temporary variable 895 psF32 sumDiffs = 0.0; // temporary variable 896 896 // psF32 sum1; 897 897 // psF32 sum2; … … 982 982 stats->sampleStdev = (1.0 / PS_SQRT_F32(errorDivisor)); 983 983 } else { 984 countFloat = ( float)countInt;984 countFloat = (psF32)countInt; 985 985 stats->sampleStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1)); 986 986 … … 1003 1003 -2: warning 1004 1004 *****************************************************************************/ 1005 intp_psVectorClippedStats(const psVector* restrict myVector,1006 const psVector* restrict errors,1007 const psVector* restrict maskVector,1008 psU32 maskVal,1009 psStats* stats)1005 psS32 p_psVectorClippedStats(const psVector* restrict myVector, 1006 const psVector* restrict errors, 1007 const psVector* restrict maskVector, 1008 psU32 maskVal, 1009 psStats* stats) 1010 1010 { 1011 1011 psS32 i = 0; // Loop index variable 1012 1012 psS32 j = 0; // Loop index variable 1013 floatclippedMean = 0.0; // self-explanatory1014 floatclippedStdev = 0.0; // self-explanatory1015 floatoldStanMean = 0.0; // Temporary variable1016 floatoldStanStdev = 0.0; // Temporary variable1013 psF32 clippedMean = 0.0; // self-explanatory 1014 psF32 clippedStdev = 0.0; // self-explanatory 1015 psF32 oldStanMean = 0.0; // Temporary variable 1016 psF32 oldStanStdev = 0.0; // Temporary variable 1017 1017 psVector* tmpMask = NULL; // Temporary vector 1018 1018 … … 1240 1240 XXX: Create a 2nd-order polynomial version and solve for X analytically. 1241 1241 *****************************************************************************/ 1242 floatp_ps1DPolyMedian(psPolynomial1D* myPoly,1243 floatrangeLow,1244 floatrangeHigh,1245 floatgetThisValue)1242 psF32 p_ps1DPolyMedian(psPolynomial1D* myPoly, 1243 psF32 rangeLow, 1244 psF32 rangeHigh, 1245 psF32 getThisValue) 1246 1246 { 1247 1247 PS_POLY_CHECK_NULL(myPoly, NAN); … … 1250 1250 // falls within the range of y-values of the polynomial "myPoly" in the 1251 1251 // specified x-range (rangeLow:rangeHigh). 1252 floatfLo = psPolynomial1DEval(1252 psF32 fLo = psPolynomial1DEval( 1253 1253 myPoly, 1254 1254 rangeLow 1255 1255 ); 1256 floatfHi = psPolynomial1DEval(1256 psF32 fHi = psPolynomial1DEval( 1257 1257 myPoly, 1258 1258 rangeHigh … … 1266 1266 1267 1267 psS32 numIterations = 0; 1268 floatmidpoint = 0.0;1269 floatoldMidpoint = 1.0;1270 floatf = 0.0;1268 psF32 midpoint = 0.0; 1269 psF32 oldMidpoint = 1.0; 1270 psF32 f = 0.0; 1271 1271 1272 1272 while (numIterations < PS_POLY_MEDIAN_MAX_ITERATIONS) { … … 1309 1309 tests to ensure that binNum is within acceptable ranges for both vectors. 1310 1310 *****************************************************************************/ 1311 floatfitQuadraticSearchForYThenReturnX(psVector *xVec,1311 psF32 fitQuadraticSearchForYThenReturnX(psVector *xVec, 1312 1312 psVector *yVec, 1313 1313 psS32 binNum, 1314 floatyVal)1314 psF32 yVal) 1315 1315 { 1316 1316 PS_VECTOR_CHECK_NULL(xVec, NAN); … … 1331 1331 psPolynomial1D *myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD); 1332 1332 1333 floattmpFloat;1333 psF32 tmpFloat; 1334 1334 1335 1335 if ((binNum > 0) && (binNum < (yVec->n - 2))) { 1336 1336 // The general case. We have all three points. 1337 x->data.F64[0] = ( double) (0.5 * (xVec->data.F32[binNum - 1] + xVec->data.F32[binNum]));1338 x->data.F64[1] = ( double) (0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum+1]));1339 x->data.F64[2] = ( double) (0.5 * (xVec->data.F32[binNum+1] + xVec->data.F32[binNum+2]));1337 x->data.F64[0] = (psF64) (0.5 * (xVec->data.F32[binNum - 1] + xVec->data.F32[binNum])); 1338 x->data.F64[1] = (psF64) (0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum+1])); 1339 x->data.F64[2] = (psF64) (0.5 * (xVec->data.F32[binNum+1] + xVec->data.F32[binNum+2])); 1340 1340 y->data.F64[0] = yVec->data.F32[binNum - 1]; 1341 1341 y->data.F64[1] = yVec->data.F32[binNum]; … … 1346 1346 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 1347 1347 PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE, 1348 ( double)yVal,y->data.F64[2],y->data.F64[0]);1348 (psF64)yVal,y->data.F64[2],y->data.F64[0]); 1349 1349 } 1350 1350 yErr->data.F64[0] = 1.0; … … 1425 1425 XXX: Check for errors in psLib routines that we call. 1426 1426 *****************************************************************************/ 1427 intp_psVectorRobustStats(const psVector* restrict myVector,1428 const psVector* restrict errors,1429 const psVector* restrict maskVector,1430 psU32 maskVal,1431 psStats* stats)1427 psS32 p_psVectorRobustStats(const psVector* restrict myVector, 1428 const psVector* restrict errors, 1429 const psVector* restrict maskVector, 1430 psU32 maskVal, 1431 psStats* stats) 1432 1432 { 1433 1433 psHistogram* robustHistogram = NULL; 1434 1434 psVector* robustHistogramVector = NULL; 1435 floatbinSize = 0.0; // Size of the histogram bins1435 psF32 binSize = 0.0; // Size of the histogram bins 1436 1436 psS32 LQBinNum = -1; // Bin num for lower quartile 1437 1437 psS32 UQBinNum = -1; // Bin num for upper quartile … … 1439 1439 psS32 i = 0; // Loop index variable 1440 1440 psS32 modeBinNum = 0; 1441 floatmodeBinCount = 0.0;1442 floatdL = 0.0;1441 psF32 modeBinCount = 0.0; 1442 psF32 dL = 0.0; 1443 1443 psS32 numBins = 0; 1444 floatmyMean = 0.0;1445 floatmyStdev = 0.0;1446 floatcountFloat = 0.0;1447 floatdiff = 0.0;1448 floatsumSquares = 0.0;1449 floatsumDiffs = 0.0;1444 psF32 myMean = 0.0; 1445 psF32 myStdev = 0.0; 1446 psF32 countFloat = 0.0; 1447 psF32 diff = 0.0; 1448 psF32 sumSquares = 0.0; 1449 psF32 sumDiffs = 0.0; 1450 1450 psVector* cumulativeRobustSums = NULL; 1451 floatsumRobust = 0.0;1452 floatsumN50 = 0.0;1453 floatsumNfit = 0.0;1451 psF32 sumRobust = 0.0; 1452 psF32 sumN50 = 0.0; 1453 psF32 sumNfit = 0.0; 1454 1454 psScalar tmpScalar; 1455 1455 tmpScalar.type.type = PS_TYPE_F32; … … 1460 1460 // that by 10.0; 1461 1461 //XXX: add errors 1462 intrc = p_psVectorClippedStats(myVector, NULL, maskVector, maskVal, tmpStats);1462 psS32 rc = p_psVectorClippedStats(myVector, NULL, maskVector, maskVal, tmpStats); 1463 1463 if (rc != 0) { 1464 1464 psError(PS_ERR_UNEXPECTED_NULL, … … 1614 1614 for (i=0;i<robustHistogramVector->n;i++) { 1615 1615 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1616 ((psVector *) (myCoords->data[i]))->data.F32[0] = ( float) i;1616 ((psVector *) (myCoords->data[i]))->data.F32[0] = (psF32) i; 1617 1617 y->data.F32[i] = robustHistogramVector->data.F32[i]; 1618 1618 } … … 1770 1770 The histogram structure 1771 1771 *****************************************************************************/ 1772 psHistogram* psHistogramAlloc( float lower, floatupper, psS32 n)1772 psHistogram* psHistogramAlloc(psF32 lower, psF32 upper, psS32 n) 1773 1773 { 1774 1774 PS_INT_CHECK_POSITIVE(n, NULL); … … 1777 1777 psS32 i = 0; // Loop index variable 1778 1778 psHistogram* newHist = NULL; // The new histogram structure 1779 floatbinSize = 0.0; // The histogram bin size1779 psF32 binSize = 0.0; // The histogram bin size 1780 1780 1781 1781 // Allocate memory for the new histogram structure. If there are N … … 1787 1787 1788 1788 // Calculate the bounds for each bin. 1789 binSize = (upper - lower) / ( float)n;1789 binSize = (upper - lower) / (psF32)n; 1790 1790 // XXX: Is the following necessary? It prevents the max data point 1791 1791 // from being in a non-existant bin. 1792 1792 binSize += FLT_EPSILON; 1793 1793 for (i = 0; i < n + 1; i++) { 1794 newHist->bounds->data.F32[i] = lower + (binSize * ( float)i);1794 newHist->bounds->data.F32[i] = lower + (binSize * (psF32)i); 1795 1795 } 1796 1796 … … 1857 1857 } 1858 1858 1859 /***************************************************************************** 1860 UpdateHistogramBins(binNum, out, data, error): This routine is to be used when 1861 updating the histogram in the presence of errors in the input data. We treat 1862 the data point as a boxcar PDF and update a range of points surrounding the 1863 histogram bin which contains the point. The width of that boxcar is defined 1864 as 2.35 * error. Inputs: 1865 binNum: the bin number of the data point in the histogram 1866 out: the histogram structure 1867 data: the data point value 1868 error: the error in that data point 1869 1870 XXX: Must test this. 1871 *****************************************************************************/ 1859 1872 psS32 UpdateHistogramBins(psS32 binNum, 1860 1873 psHistogram* out, … … 1863 1876 { 1864 1877 PS_PTR_CHECK_NULL(out, -1); 1865 PS_INT_CHECK_RANGE(binNum, 0, out->nums->n-1, -2); 1866 /* 1867 psF32 width = 2.35 * error; 1868 psF32 centerBinWidth = out->bounds->data.F32[binNum+1] - out->bounds->data.F32[binNum] 1869 psF32 boxcarCenter = (out->bounds->data.F32[binNum] + out->bounds->data.F32[binNum+1]) / 2.0; 1870 1871 if (width <= centerBinWidth) { 1872 out->nums->data.F32[binNum]+= 1.0; 1873 } else { 1874 out->nums->data.F32[binNum]+= centerBinWidth / width; 1875 // XXX: walk to the left, adding fractional values. 1876 // XXX: walk to the right, adding fractional values. 1877 1878 1879 } 1880 */ 1878 PS_PTR_CHECK_NULL(out->bounds, -1); 1879 PS_PTR_CHECK_NULL(out->nums, -1); 1880 PS_INT_CHECK_RANGE(binNum, 0, ((out->nums->n)-1), -2); 1881 PS_FLOAT_COMPARE(0.0, error, -3); 1882 PS_FLOAT_CHECK_RANGE(data, out->bounds->data.F32[0], out->bounds->data.F32[(out->bounds->n)-1], -4); 1883 1884 psF32 boxcarWidth = 2.35 * error; 1885 psF32 boxcarCenter = (out->bounds->data.F32[binNum] + 1886 out->bounds->data.F32[binNum+1]) / 2.0; 1887 psF32 boxcarLeft = boxcarCenter - (boxcarWidth / 2.0); 1888 psF32 boxcarRight = boxcarCenter + (boxcarWidth / 2.0); 1889 psS32 bin; 1890 psS32 boxcarLeftBinNum; 1891 psS32 boxcarRightBinNum; 1892 1893 // Determine the left endpoint of the boxcar for the PDF. 1894 for (bin=binNum ; bin >= 0 ; bin--) { 1895 if (out->nums->data.F32[bin] <= boxcarLeft) { 1896 boxcarLeftBinNum = bin; 1897 break; 1898 } 1899 } 1900 1901 // Determine the right endpoint of the boxcar for the PDF. 1902 for (bin=binNum ; bin < out->nums->n ; bin++) { 1903 if (out->nums->data.F32[bin] >= boxcarRight) { 1904 boxcarRightBinNum = bin; 1905 break; 1906 } 1907 } 1908 1909 // 1910 // If the boxcar fits entirely inside this bin, then simply add 1.0 to the 1911 // bin and return. 1912 // 1913 if (boxcarLeftBinNum == boxcarRightBinNum) { 1914 out->nums->data.F32[binNum]+= 1.0; 1915 return(0); 1916 } 1917 1918 // 1919 // If we get here, multiple bins must be updated. We handle the left 1920 // endpoint, and right endpoint differently. 1921 // 1922 out->nums->data.F32[boxcarLeftBinNum]+= 1923 (out->bounds->data.F32[boxcarLeftBinNum+1] - boxcarLeft) / boxcarWidth; 1924 1925 // 1926 // Loop through the center bins, if any. 1927 // 1928 for (bin = boxcarLeftBinNum + 1 ; bin < (boxcarRightBinNum - 1) ; bin++) { 1929 out->nums->data.F32[bin]+= 1930 (out->bounds->data.F32[bin+1] - out->bounds->data.F32[bin]) / boxcarWidth; 1931 } 1932 1933 // 1934 // Handle the right endpoint differently. 1935 // 1936 out->nums->data.F32[boxcarRightBinNum]+= 1937 (boxcarRight - out->bounds->data.F32[boxcarRightBinNum]) / boxcarWidth; 1938 1939 // 1940 // Return 0 on success. 1941 // 1881 1942 return(0); 1882 1943 } … … 1906 1967 { 1907 1968 PS_PTR_CHECK_NULL(out, NULL); 1969 PS_VECTOR_CHECK_NULL(out->bounds, NULL); 1908 1970 PS_VECTOR_CHECK_TYPE(out->bounds, PS_TYPE_F32, NULL); 1971 PS_INT_CHECK_NON_NEGATIVE(out->bounds->n, NULL); 1972 PS_VECTOR_CHECK_NULL(out->nums, NULL); 1909 1973 PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_F32, NULL); 1910 1974 PS_INT_CHECK_NON_NEGATIVE(out->nums->n, NULL); … … 1920 1984 1921 1985 psS32 i = 0; // Loop index variable 1922 floatbinSize = 0.0; // Histogram bin size1986 psF32 binSize = 0.0; // Histogram bin size 1923 1987 psS32 binNum = 0; // A temporary bin number 1924 1988 psS32 numBins = 0; // The total number of bins 1925 psS32 tmp = 0;1926 1989 psScalar tmpScalar; 1927 1990 tmpScalar.type.type = PS_TYPE_F32; 1928 psVector* inF32; 1929 psS32 mustFreeTmp = 1; 1991 psVector* inF32 = NULL; 1992 psVector* errorsF32 = NULL; 1993 psS32 mustFreeVectorIn = 1; 1994 psS32 mustFreeVectorErrors = 1; 1995 1996 // Convert input and errors vectors to F32 if necessary. 1930 1997 inF32 = p_psConvertToF32((psVector *) in); 1931 1998 if (inF32 == NULL) { 1932 1999 inF32 = (psVector *) in; 1933 mustFreeTmp = 0; 2000 mustFreeVectorIn = 0; 2001 } 2002 errorsF32 = p_psConvertToF32((psVector *) errors); 2003 if (errorsF32 == NULL) { 2004 errorsF32 = (psVector *) errors; 2005 mustFreeVectorErrors = 0; 1934 2006 } 1935 2007 … … 1950 2022 binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; 1951 2023 binNum = (psS32)((inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize); 1952 if (errors != NULL) {2024 if (errorsF32 != NULL) { 1953 2025 // XXX: Check return codes. 1954 2026 UpdateHistogramBins(binNum, out, 1955 2027 inF32->data.F32[i], 1956 errors ->data.F32[i]);2028 errorsF32->data.F32[i]); 1957 2029 } else { 1958 2030 // XXX: This if-statement really shouldn't be necessary. … … 1969 2041 // correct bin number requires a bit more work. 1970 2042 tmpScalar.data.F32 = inF32->data.F32[i]; 1971 tmp= p_psVectorBinDisect(out->bounds, &tmpScalar);1972 if ( tmp< 0) {2043 binNum = p_psVectorBinDisect(out->bounds, &tmpScalar); 2044 if (binNum < 0) { 1973 2045 psLogMsg(__func__, PS_LOG_WARN, 1974 2046 "WARNING: psVectorHistogram(): element outside histogram bounds.\n"); 1975 2047 } else { 1976 if (errors != NULL) {2048 if (errorsF32 != NULL) { 1977 2049 // XXX: Check return codes. 1978 UpdateHistogramBins( tmp, out,2050 UpdateHistogramBins(binNum, out, 1979 2051 inF32->data.F32[i], 1980 2052 errors->data.F32[i]); 1981 2053 } else { 1982 (out->nums->data.F32[ tmp])+= 1.0;2054 (out->nums->data.F32[binNum])+= 1.0; 1983 2055 } 1984 2056 } … … 1988 2060 } 1989 2061 1990 if (mustFree Tmp== 1) {2062 if (mustFreeVectorIn == 1) { 1991 2063 psFree(inF32); 2064 } 2065 if (mustFreeVectorErrors == 1) { 2066 psFree(errorsF32); 1992 2067 } 1993 2068 return (out); … … 2015 2090 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2016 2091 for (i = 0; i < in->n; i++) { 2017 tmp->data.F32[i] = (float)in->data.S8[i]; 2092 tmp->data.F32[i] = (psF32)in->data.S8[i]; 2093 } 2094 } else if (in->type.type == PS_TYPE_S16) { 2095 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2096 for (i = 0; i < in->n; i++) { 2097 tmp->data.F32[i] = (psF32) in->data.S16[i]; 2098 } 2099 } else if (in->type.type == PS_TYPE_S32) { 2100 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2101 for (i = 0; i < in->n; i++) { 2102 tmp->data.F32[i] = (psF32)in->data.S32[i]; 2103 } 2104 } else if (in->type.type == PS_TYPE_S64) { 2105 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2106 for (i = 0; i < in->n; i++) { 2107 tmp->data.F32[i] = (psF32)in->data.S64[i]; 2108 } 2109 } else if (in->type.type == PS_TYPE_U8) { 2110 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2111 for (i = 0; i < in->n; i++) { 2112 tmp->data.F32[i] = (psF32)in->data.U8[i]; 2018 2113 } 2019 2114 } else if (in->type.type == PS_TYPE_U16) { 2020 2115 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2021 2116 for (i = 0; i < in->n; i++) { 2022 tmp->data.F32[i] = ( float)in->data.U16[i];2023 } 2024 } else if (in->type.type == PS_TYPE_U 8) {2117 tmp->data.F32[i] = (psF32)in->data.U16[i]; 2118 } 2119 } else if (in->type.type == PS_TYPE_U32) { 2025 2120 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2026 2121 for (i = 0; i < in->n; i++) { 2027 tmp->data.F32[i] = (float)in->data.U8[i]; 2122 tmp->data.F32[i] = (psF32)in->data.U32[i]; 2123 } 2124 } else if (in->type.type == PS_TYPE_U64) { 2125 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2126 for (i = 0; i < in->n; i++) { 2127 tmp->data.F32[i] = (psF32)in->data.U64[i]; 2028 2128 } 2029 2129 } else if (in->type.type == PS_TYPE_F64) { 2030 2130 tmp = psVectorAlloc(in->n, PS_TYPE_F32); 2031 2131 for (i = 0; i < in->n; i++) { 2032 tmp->data.F32[i] = ( float)in->data.F64[i];2132 tmp->data.F32[i] = (psF32)in->data.F64[i]; 2033 2133 } 2034 2134 } else if (in->type.type == PS_TYPE_F32) { 2035 2135 // do nothing 2036 2136 } else { 2037 char* strType;2038 PS_TYPE_NAME(strType, in->type.type);2137 psS8* strType; 2138 PS_TYPE_NAME(strType, in->type.type); 2039 2139 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 2040 2140 PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED, … … 2074 2174 } 2075 2175 2076 psVector* inF32 ;2077 psVector* errorsF32 ;2176 psVector* inF32 = NULL; 2177 psVector* errorsF32 = NULL; 2078 2178 psS32 mustFreeVectorIn = 1; 2079 2179 psS32 mustFreeVectorErrors = 1; … … 2178 2278 return (stats); 2179 2279 } 2280
Note:
See TracChangeset
for help on using the changeset viewer.
