IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 21, 2004, 7:09:32 PM (22 years ago)
Author:
gusciora
Message:

Changed types to PS types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r2782 r2788  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-12-22 00:54:28 $
     11 *  @version $Revision: 1.108 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-12-22 05:09:32 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070/*****************************************************************************/
    7171
    72 psBool p_psGetStatValue(const psStats* stats, double *value)
     72psBool p_psGetStatValue(const psStats* stats, psF64 *value)
    7373{
    7474
     
    145145this routine sets stats->sampleMean to NAN.
    146146 *****************************************************************************/
    147 int p_psVectorSampleMean(const psVector* restrict myVector,
    148                          const psVector* restrict errors,
    149                          const psVector* restrict maskVector,
    150                          psU32 maskVal,
    151                          psStats* stats)
     147psS32 p_psVectorSampleMean(const psVector* restrict myVector,
     148                           const psVector* restrict errors,
     149                           const psVector* restrict maskVector,
     150                           psU32 maskVal,
     151                           psStats* stats)
    152152{
    153153
    154154    psS32 i = 0;                // Loop index variable
    155     float mean = 0.0;           // The mean
     155    psF32 mean = 0.0;           // The mean
    156156    psS32 count = 0;            // # of points in this mean
    157157
     
    171171                }
    172172                if (count != 0) {
    173                     mean /= (float)count;
     173                    mean /= (psF32)count;
    174174                } else {
    175175                    mean = NAN;
     
    185185                }
    186186                if (count != 0) {
    187                     mean /= (float)count;
     187                    mean /= (psF32)count;
    188188                } else {
    189189                    mean = NAN;
     
    199199                }
    200200                if (count != 0) {
    201                     mean /= (float)count;
     201                    mean /= (psF32)count;
    202202                } else {
    203203                    mean = NAN;
     
    207207                    mean += myVector->data.F32[i];
    208208                }
    209                 mean /= (float)myVector->n;
     209                mean /= (psF32)myVector->n;
    210210            }
    211211        }
     
    283283this routine sets stats->max to NAN.
    284284 *****************************************************************************/
    285 int p_psVectorMax(const psVector* restrict myVector,
    286                   const psVector* restrict maskVector,
    287                   psU32 maskVal,
    288                   psStats* stats)
     285psS32 p_psVectorMax(const psVector* restrict myVector,
     286                    const psVector* restrict maskVector,
     287                    psU32 maskVal,
     288                    psStats* stats)
    289289{
    290290    psS32 i = 0;                // Loop index variable
    291     float max = -PS_MAX_F32;    // The calculated maximum
     291    psF32 max = -PS_MAX_F32;    // The calculated maximum
    292292    psS32 empty = true;         // Does this vector have valid elements?
    293293
     
    348348this routine sets stats->min to NAN.
    349349 *****************************************************************************/
    350 int p_psVectorMin(const psVector* restrict myVector,
    351                   const psVector* restrict maskVector,
    352                   psU32 maskVal,
    353                   psStats* stats)
     350psS32 p_psVectorMin(const psVector* restrict myVector,
     351                    const psVector* restrict maskVector,
     352                    psU32 maskVal,
     353                    psStats* stats)
    354354{
    355355    psS32 i = 0;                // Loop index variable
    356     float min = PS_MAX_F32;   // The calculated maximum
     356    psF32 min = PS_MAX_F32;   // The calculated maximum
    357357    psS32 empty = true;         // Does this vector have valid elements?
    358358
     
    612612 *****************************************************************************/
    613613psVector* p_psVectorSmoothHistGaussian(psHistogram* robustHistogram,
    614                                        float sigma)
     614                                       psF32 sigma)
    615615{
    616616    PS_PTR_CHECK_NULL(robustHistogram, NULL);
     
    619619    psS32 i = 0;                  // Loop index variable
    620620    psS32 j = 0;                  // Loop index variable
    621     float iMid;
    622     float jMid;
     621    psF32 iMid;
     622    psF32 jMid;
    623623    psS32 numBins = robustHistogram->nums->n;
    624624    psS32 numBounds = robustHistogram->bounds->n;
     
    626626    psS32 jMin = 0;
    627627    psS32 jMax = 0;
    628     float firstBound = robustHistogram->bounds->data.F32[0];
    629     float lastBound = robustHistogram->bounds->data.F32[numBounds-1];
     628    psF32 firstBound = robustHistogram->bounds->data.F32[0];
     629    psF32 lastBound = robustHistogram->bounds->data.F32[numBounds-1];
    630630    psScalar x;
    631631
     
    795795    psS32 i = 0;                  // Loop index variable
    796796    psS32 countInt = 0;           // # of data points being used
    797     float countFloat = 0.0;     // # of data points being used
    798     float mean = 0.0;           // The mean
    799     float diff = 0.0;           // Used in calculating stdev
    800     float sumSquares = 0.0;     // temporary variable
    801     float sumDiffs = 0.0;       // temporary variable
     797    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
    802802
    803803    // This procedure requires the mean.  If it has not been already
     
    865865        psLogMsg(__func__, PS_LOG_WARN, "WARNING: p_psVectorSampleStdev(): only one valid psVector elements (%d).  Setting stats->sampleStdev = 0.0.\n", countInt);
    866866    } else {
    867         countFloat = (float)countInt;
     867        countFloat = (psF32)countInt;
    868868        stats->sampleStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1));
    869869    }
     
    889889    psS32 i = 0;                  // Loop index variable
    890890    psS32 countInt = 0;           // # of data points being used
    891     float countFloat = 0.0;     // # of data points being used
    892     float mean = 0.0;           // The mean
    893     float diff = 0.0;           // Used in calculating stdev
    894     float sumSquares = 0.0;     // temporary variable
    895     float sumDiffs = 0.0;       // temporary variable
     891    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
    896896    //    psF32 sum1;
    897897    //    psF32 sum2;
     
    982982            stats->sampleStdev = (1.0 / PS_SQRT_F32(errorDivisor));
    983983        } else {
    984             countFloat = (float)countInt;
     984            countFloat = (psF32)countInt;
    985985            stats->sampleStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1));
    986986
     
    10031003    -2: warning
    10041004 *****************************************************************************/
    1005 int p_psVectorClippedStats(const psVector* restrict myVector,
    1006                            const psVector* restrict errors,
    1007                            const psVector* restrict maskVector,
    1008                            psU32 maskVal,
    1009                            psStats* stats)
     1005psS32 p_psVectorClippedStats(const psVector* restrict myVector,
     1006                             const psVector* restrict errors,
     1007                             const psVector* restrict maskVector,
     1008                             psU32 maskVal,
     1009                             psStats* stats)
    10101010{
    10111011    psS32 i = 0;                  // Loop index variable
    10121012    psS32 j = 0;                  // Loop index variable
    1013     float clippedMean = 0.0;    // self-explanatory
    1014     float clippedStdev = 0.0;   // self-explanatory
    1015     float oldStanMean = 0.0;    // Temporary variable
    1016     float oldStanStdev = 0.0;   // Temporary variable
     1013    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
    10171017    psVector* tmpMask = NULL;   // Temporary vector
    10181018
     
    12401240XXX: Create a 2nd-order polynomial version and solve for X analytically.
    12411241 *****************************************************************************/
    1242 float p_ps1DPolyMedian(psPolynomial1D* myPoly,
    1243                        float rangeLow,
    1244                        float rangeHigh,
    1245                        float getThisValue)
     1242psF32 p_ps1DPolyMedian(psPolynomial1D* myPoly,
     1243                       psF32 rangeLow,
     1244                       psF32 rangeHigh,
     1245                       psF32 getThisValue)
    12461246{
    12471247    PS_POLY_CHECK_NULL(myPoly, NAN);
     
    12501250    // falls within the range of y-values of the polynomial "myPoly" in the
    12511251    // specified x-range (rangeLow:rangeHigh).
    1252     float fLo = psPolynomial1DEval(
     1252    psF32 fLo = psPolynomial1DEval(
    12531253                    myPoly,
    12541254                    rangeLow
    12551255                );
    1256     float fHi = psPolynomial1DEval(
     1256    psF32 fHi = psPolynomial1DEval(
    12571257                    myPoly,
    12581258                    rangeHigh
     
    12661266
    12671267    psS32 numIterations = 0;
    1268     float midpoint = 0.0;
    1269     float oldMidpoint = 1.0;
    1270     float f = 0.0;
     1268    psF32 midpoint = 0.0;
     1269    psF32 oldMidpoint = 1.0;
     1270    psF32 f = 0.0;
    12711271
    12721272    while (numIterations < PS_POLY_MEDIAN_MAX_ITERATIONS) {
     
    13091309tests to ensure that binNum is within acceptable ranges for both vectors.
    13101310*****************************************************************************/
    1311 float fitQuadraticSearchForYThenReturnX(psVector *xVec,
     1311psF32 fitQuadraticSearchForYThenReturnX(psVector *xVec,
    13121312                                        psVector *yVec,
    13131313                                        psS32 binNum,
    1314                                         float yVal)
     1314                                        psF32 yVal)
    13151315{
    13161316    PS_VECTOR_CHECK_NULL(xVec, NAN);
     
    13311331    psPolynomial1D *myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD);
    13321332
    1333     float tmpFloat;
     1333    psF32 tmpFloat;
    13341334
    13351335    if ((binNum > 0) && (binNum < (yVec->n - 2))) {
    13361336        // 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]));
    13401340        y->data.F64[0] = yVec->data.F32[binNum - 1];
    13411341        y->data.F64[1] = yVec->data.F32[binNum];
     
    13461346            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    13471347                    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]);
    13491349        }
    13501350        yErr->data.F64[0] = 1.0;
     
    14251425XXX: Check for errors in psLib routines that we call.
    14261426*****************************************************************************/
    1427 int p_psVectorRobustStats(const psVector* restrict myVector,
    1428                           const psVector* restrict errors,
    1429                           const psVector* restrict maskVector,
    1430                           psU32 maskVal,
    1431                           psStats* stats)
     1427psS32 p_psVectorRobustStats(const psVector* restrict myVector,
     1428                            const psVector* restrict errors,
     1429                            const psVector* restrict maskVector,
     1430                            psU32 maskVal,
     1431                            psStats* stats)
    14321432{
    14331433    psHistogram* robustHistogram = NULL;
    14341434    psVector* robustHistogramVector = NULL;
    1435     float binSize = 0.0;        // Size of the histogram bins
     1435    psF32 binSize = 0.0;        // Size of the histogram bins
    14361436    psS32 LQBinNum = -1;          // Bin num for lower quartile
    14371437    psS32 UQBinNum = -1;          // Bin num for upper quartile
     
    14391439    psS32 i = 0;                  // Loop index variable
    14401440    psS32 modeBinNum = 0;
    1441     float modeBinCount = 0.0;
    1442     float dL = 0.0;
     1441    psF32 modeBinCount = 0.0;
     1442    psF32 dL = 0.0;
    14431443    psS32 numBins = 0;
    1444     float myMean = 0.0;
    1445     float myStdev = 0.0;
    1446     float countFloat = 0.0;
    1447     float diff = 0.0;
    1448     float sumSquares = 0.0;
    1449     float sumDiffs = 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;
    14501450    psVector* cumulativeRobustSums = NULL;
    1451     float sumRobust = 0.0;
    1452     float sumN50 = 0.0;
    1453     float sumNfit = 0.0;
     1451    psF32 sumRobust = 0.0;
     1452    psF32 sumN50 = 0.0;
     1453    psF32 sumNfit = 0.0;
    14541454    psScalar tmpScalar;
    14551455    tmpScalar.type.type = PS_TYPE_F32;
     
    14601460    // that by 10.0;
    14611461    //XXX: add errors
    1462     int rc = p_psVectorClippedStats(myVector, NULL, maskVector, maskVal, tmpStats);
     1462    psS32 rc = p_psVectorClippedStats(myVector, NULL, maskVector, maskVal, tmpStats);
    14631463    if (rc != 0) {
    14641464        psError(PS_ERR_UNEXPECTED_NULL,
     
    16141614    for (i=0;i<robustHistogramVector->n;i++) {
    16151615        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;
    16171617        y->data.F32[i] = robustHistogramVector->data.F32[i];
    16181618    }
     
    17701770    The histogram structure
    17711771 *****************************************************************************/
    1772 psHistogram* psHistogramAlloc(float lower, float upper, psS32 n)
     1772psHistogram* psHistogramAlloc(psF32 lower, psF32 upper, psS32 n)
    17731773{
    17741774    PS_INT_CHECK_POSITIVE(n, NULL);
     
    17771777    psS32 i = 0;                  // Loop index variable
    17781778    psHistogram* newHist = NULL;        // The new histogram structure
    1779     float binSize = 0.0;        // The histogram bin size
     1779    psF32 binSize = 0.0;        // The histogram bin size
    17801780
    17811781    // Allocate memory for the new histogram structure.  If there are N
     
    17871787
    17881788    // Calculate the bounds for each bin.
    1789     binSize = (upper - lower) / (float)n;
     1789    binSize = (upper - lower) / (psF32)n;
    17901790    // XXX: Is the following necessary? It prevents the max data point
    17911791    // from being in a non-existant bin.
    17921792    binSize += FLT_EPSILON;
    17931793    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);
    17951795    }
    17961796
     
    18571857}
    18581858
     1859/*****************************************************************************
     1860UpdateHistogramBins(binNum, out, data, error): This routine is to be used when
     1861updating the histogram in the presence of errors in the input data.  We treat
     1862the data point as a boxcar PDF and update a range of points surrounding the
     1863histogram bin which contains the point.  The width of that boxcar is defined
     1864as 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 
     1870XXX: Must test this.
     1871 *****************************************************************************/
    18591872psS32 UpdateHistogramBins(psS32 binNum,
    18601873                          psHistogram* out,
     
    18631876{
    18641877    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    //
    18811942    return(0);
    18821943}
     
    19061967{
    19071968    PS_PTR_CHECK_NULL(out, NULL);
     1969    PS_VECTOR_CHECK_NULL(out->bounds, NULL);
    19081970    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);
    19091973    PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_F32, NULL);
    19101974    PS_INT_CHECK_NON_NEGATIVE(out->nums->n, NULL);
     
    19201984
    19211985    psS32 i = 0;                  // Loop index variable
    1922     float binSize = 0.0;          // Histogram bin size
     1986    psF32 binSize = 0.0;          // Histogram bin size
    19231987    psS32 binNum = 0;             // A temporary bin number
    19241988    psS32 numBins = 0;            // The total number of bins
    1925     psS32 tmp = 0;
    19261989    psScalar tmpScalar;
    19271990    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.
    19301997    inF32 = p_psConvertToF32((psVector *) in);
    19311998    if (inF32 == NULL) {
    19321999        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;
    19342006    }
    19352007
     
    19502022                    binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0];
    19512023                    binNum = (psS32)((inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize);
    1952                     if (errors != NULL) {
     2024                    if (errorsF32 != NULL) {
    19532025                        // XXX: Check return codes.
    19542026                        UpdateHistogramBins(binNum, out,
    19552027                                            inF32->data.F32[i],
    1956                                             errors->data.F32[i]);
     2028                                            errorsF32->data.F32[i]);
    19572029                    } else {
    19582030                        // XXX: This if-statement really shouldn't be necessary.
     
    19692041                    // correct bin number requires a bit more work.
    19702042                    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) {
    19732045                        psLogMsg(__func__, PS_LOG_WARN,
    19742046                                 "WARNING: psVectorHistogram(): element outside histogram bounds.\n");
    19752047                    } else {
    1976                         if (errors != NULL) {
     2048                        if (errorsF32 != NULL) {
    19772049                            // XXX: Check return codes.
    1978                             UpdateHistogramBins(tmp, out,
     2050                            UpdateHistogramBins(binNum, out,
    19792051                                                inF32->data.F32[i],
    19802052                                                errors->data.F32[i]);
    19812053                        } else {
    1982                             (out->nums->data.F32[tmp])+= 1.0;
     2054                            (out->nums->data.F32[binNum])+= 1.0;
    19832055                        }
    19842056                    }
     
    19882060    }
    19892061
    1990     if (mustFreeTmp == 1) {
     2062    if (mustFreeVectorIn == 1) {
    19912063        psFree(inF32);
     2064    }
     2065    if (mustFreeVectorErrors == 1) {
     2066        psFree(errorsF32);
    19922067    }
    19932068    return (out);
     
    20152090        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
    20162091        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];
    20182113        }
    20192114    } else if (in->type.type == PS_TYPE_U16) {
    20202115        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
    20212116        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_U8) {
     2117            tmp->data.F32[i] = (psF32)in->data.U16[i];
     2118        }
     2119    } else if (in->type.type == PS_TYPE_U32) {
    20252120        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
    20262121        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];
    20282128        }
    20292129    } else if (in->type.type == PS_TYPE_F64) {
    20302130        tmp = psVectorAlloc(in->n, PS_TYPE_F32);
    20312131        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];
    20332133        }
    20342134    } else if (in->type.type == PS_TYPE_F32) {
    20352135        // do nothing
    20362136    } else {
    2037         char* strType;
    2038         PS_TYPE_NAME(strType,in->type.type);
     2137        psS8* strType;
     2138        PS_TYPE_NAME(strType, in->type.type);
    20392139        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    20402140                PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED,
     
    20742174    }
    20752175
    2076     psVector* inF32;
    2077     psVector* errorsF32;
     2176    psVector* inF32 = NULL;
     2177    psVector* errorsF32 = NULL;
    20782178    psS32 mustFreeVectorIn = 1;
    20792179    psS32 mustFreeVectorErrors = 1;
     
    21782278    return (stats);
    21792279}
     2280
Note: See TracChangeset for help on using the changeset viewer.