IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 18, 2005, 10:30:35 AM (21 years ago)
Author:
gusciora
Message:

Improved the non-uniform code for p_psVectorSmoothHistGaussian(). Not yet
tested, or used anywhere.

CVS:


Enter Log. Lines beginning with `CVS:' are removed automatically CVS: CVS:
Committing in . CVS: CVS: Modified Files: CVS: src/math/psStats.c
test/math/verified/tst_psStats07.stderr CVS:


File:
1 edited

Legend:

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

    r5530 r5548  
    1717*
    1818*
    19 *  @version $Revision: 1.151 $ $Name: not supported by cvs2svn $
    20 *  @date $Date: 2005-11-16 23:06:19 $
     19*  @version $Revision: 1.152 $ $Name: not supported by cvs2svn $
     20*  @date $Date: 2005-11-18 20:30:35 $
    2121*
    2222*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    661661call that.  Is that possible?
    662662 *****************************************************************************/
    663 psVector *p_psVectorSmoothHistGaussian(psHistogram *histogram,
    664                                        psF32 sigma)
     663psVector *p_psVectorSmoothHistGaussian(
     664    psHistogram *histogram,
     665    psF32 sigma)
    665666{
    666667    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     
    674675
    675676    psS32 numBins = histogram->nums->n;
    676     psS32 numBounds = histogram->bounds->n;
    677677    psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32);
    678     psF32 firstBound = histogram->bounds->data.F32[0];
    679     psF32 lastBound = histogram->bounds->data.F32[numBounds-1];
    680     psScalar x;
    681     x.type.type = PS_TYPE_F32;
    682678    psS32 jMin = 0;
    683679    psS32 jMax = 0;
     
    685681    if (histogram->uniform == false) {
    686682        //
    687         // We get here if the histogram is non-uniform.
     683        // We get here if the histogram is non-uniform.  This code is not tested.
     684        // However, it is also not used anywhere, yet.
    688685        //
     686        psLogMsg(__func__, PS_LOG_WARN, "WARNING: p_psVectorSmoothHistGaussian() on non-uniform histograms has not been tested or used.\n");
    689687
    690688        for (psS32 i = 0; i < numBins; i++) {
     
    696694            // range of data values surrounding iMid.  The range is of size:
    697695            // 2*PS_GAUSS_WIDTH*sigma
    698             //
    699             x.data.F32 = iMid - (PS_GAUSS_WIDTH * sigma);
    700             if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    701                 jMin = p_psVectorBinDisect( *(psVector* *)&histogram->bounds, &x);
    702                 if (jMin < 0) {
    703                     psError(PS_ERR_UNEXPECTED_NULL,
    704                             false,
    705                             PS_ERRORTEXT_psStats_STATS_VECTOR_BIN_DISECT_PROBLEM);
    706                     psTrace(__func__, 4, "---- %s(NULL) end ----\n", __func__);
    707                     return(NULL);
    708                 }
    709             } else if (x.data.F32 <= firstBound) {
    710                 jMin = 0;
    711             } else if (x.data.F32 >= lastBound) {
    712                 jMin = histogram->bounds->n - 1;
    713             }
    714 
    715             x.data.F32 = iMid + (PS_GAUSS_WIDTH * sigma);
    716             if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    717                 jMax = p_psVectorBinDisect( *(psVector* *)&histogram->bounds, &x);
    718                 if (jMax < 0) {
    719                     psError(PS_ERR_UNEXPECTED_NULL,
    720                             false,
    721                             PS_ERRORTEXT_psStats_STATS_VECTOR_BIN_DISECT_PROBLEM);
    722                     psTrace(__func__, 4, "---- %s(NULL) end ----\n", __func__);
    723                     return(NULL);
    724                 }
    725             } else if (x.data.F32 <= firstBound) {
    726                 jMax = 0;
    727             } else if (x.data.F32 >= lastBound) {
    728                 jMax = histogram->bounds->n - 1;
    729             }
     696            psF32 x = iMid - (PS_GAUSS_WIDTH * sigma);
     697            jMin = i;
     698            while (jMin > 0) {
     699                if ((histogram->bounds->data.F32[jMin] <= x) &&
     700                        (histogram->bounds->data.F32[jMin+1] >= x)) {
     701                    break;
     702                }
     703                jMin--;
     704            }
     705
     706            x = iMid + (PS_GAUSS_WIDTH * sigma);
     707            jMax = i;
     708            while (jMax < (histogram->bounds->n - 1)) {
     709                if ((histogram->bounds->data.F32[jMax] <= x) &&
     710                        (histogram->bounds->data.F32[jMax+1] >= x)) {
     711                    break;
     712                }
     713                jMax++;
     714            }
     715
    730716
    731717            //
Note: See TracChangeset for help on using the changeset viewer.