IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2006, 12:55:05 PM (20 years ago)
Author:
Paul Price
Message:

Following today's meeting, we agreed that psVectorAlloc (and therefore
psArrayAlloc also) shall set the number of elements in use to equal the
number of elements allocated. We introduce new functions,
psVectorAllocEmpty and psArrayAllocEmpty, that allocate a vector and set
the length to zero.

File:
1 edited

Legend:

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

    r9540 r9730  
    1616 * use ->min and ->max (PS_STAT_USE_RANGE)
    1717 *
    18  *  @version $Revision: 1.187 $ $Name: not supported by cvs2svn $
    19  *  @date $Date: 2006-10-13 22:04:58 $
     18 *  @version $Revision: 1.188 $ $Name: not supported by cvs2svn $
     19 *  @date $Date: 2006-10-24 22:52:56 $
    2020 *
    2121 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    388388
    389389    // Allocate temporary vectors for the data.
    390     psVector* vector = psVectorAlloc(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
     390    psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
    391391    long count = 0;                     // Number of valid entries
    392392
     
    486486    long numBins = histogram->nums->n;  // Number of histogram bins
    487487    psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins
    488     smooth->n = smooth->nalloc;
    489488    const psVector *bounds = histogram->bounds; // The bounds for the histogram bins
    490489
     
    723722    // We copy the mask vector, to preserve the original
    724723    psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8);
    725     tmpMask->n = tmpMask->nalloc;
    726724    psVectorInit(tmpMask, 0);
    727725    if (maskVector) {
     
    901899    psVector *x = psVectorAlloc(3, PS_TYPE_F64);
    902900    psVector *y = psVectorAlloc(3, PS_TYPE_F64);
    903     x->n = 3;
    904     y->n = 3;
    905901    psF32 tmpFloat = 0.0f;
    906902
     
    10661062
    10671063    psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
    1068     mask->n = myVector->n;
    10691064    psVectorInit(mask, 0);
    10701065    if (maskVector) {
     
    14871482        psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates
    14881483        psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates
    1489         y->n = y->nalloc;
    1490         x->n = x->nalloc;
    14911484        for (long i = binMin, j = 0; i <= binMax ; i++, j++) {
    14921485            y->data.F32[j] = smoothed->data.F32[i];
    14931486            psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value
    1494             ordinate->n = 1;
    14951487            ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i);
    14961488            x->data[j] = ordinate;
     
    15211513        psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information
    15221514        psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian
    1523         params->n = params->nalloc;
    15241515        // Initial guess for the mean (index 0) and standard dev (index 1).
    15251516        params->data.F32[0] = stats->robustMedian;
     
    16541645    psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32);
    16551646    newHist->bounds = newBounds;
    1656     newBounds->n = newHist->bounds->nalloc;
    16571647
    16581648    // Calculate the bounds for each bin.
     
    16661656    // Allocate the bins, and initialize them to zero.
    16671657    newHist->nums = psVectorAlloc(n, PS_TYPE_F32);
    1668     for (long i = 0; i < newHist->nums->nalloc; i++) {
    1669         newHist->nums->data.F32[i] = 0.0;
    1670         newHist->nums->n++;
    1671     }
     1658    psVectorInit(newHist->nums, 0.0);
    16721659
    16731660    // Initialize the other members.
     
    16991686    psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure
    17001687    psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
    1701     psVector* newBounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
     1688    psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32);
    17021689    newHist->bounds = newBounds;
    1703     newBounds->n = newHist->bounds->nalloc;
    1704     for (long i = 0; i < bounds->n; i++) {
    1705         newBounds->data.F32[i] = bounds->data.F32[i];
    1706     }
    17071690
    17081691    // Allocate the bins, and initialize them to zero.  If there are N bounds,
    17091692    // then there are N-1 bins.
    17101693    newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32);
    1711     for (long i = 0; i < newHist->nums->nalloc; i++) {
    1712         newHist->nums->data.F32[i] = 0.0;
    1713         newHist->nums->n++;
    1714     }
     1694    psVectorInit(newHist->nums, 0.0);
    17151695
    17161696    // Initialize the other members.
Note: See TracChangeset for help on using the changeset viewer.