IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2006, 1:43:16 PM (20 years ago)
Author:
drobbin
Message:

Changed psArray & psVector to zero 'n' upon allocation. Used to set vector->n = nalloc.

File:
1 edited

Legend:

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

    r6449 r6484  
    1616 * use ->min and ->max (PS_STAT_USE_RANGE)
    1717 *
    18  *  @version $Revision: 1.169 $ $Name: not supported by cvs2svn $
    19  *  @date $Date: 2006-02-18 00:56:44 $
     18 *  @version $Revision: 1.170 $ $Name: not supported by cvs2svn $
     19 *  @date $Date: 2006-02-24 23:43:15 $
    2020 *
    2121 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    569569    // Allocate temporary vectors for the data.
    570570    unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32);
     571    unsortedVector->n = nValues;
    571572
    572573    // Determine if we must only use data points within a min/max range.
     
    657658    psS32 numBins = histogram->nums->n;
    658659    psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32);
     660    smooth->n = smooth->nalloc;
    659661    psS32 jMin = 0;
    660662    psS32 jMax = 0;
     
    783785    // Allocate temporary vectors for the data.
    784786    unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32);
     787    unsortedVector->n = unsortedVector->nalloc;
    785788
    786789    if (stats->options & PS_STAT_USE_RANGE) {
     
    10371040    // However, we do no want to modify the original mask vector.
    10381041    tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8);
     1042    tmpMask->n = tmpMask->nalloc;
    10391043
    10401044    // If we were called with a mask vector, then initialize the temporary
     
    11981202    psVector *x = psVectorAlloc(3, PS_TYPE_F64);
    11991203    psVector *y = psVectorAlloc(3, PS_TYPE_F64);
     1204    x->n = 3;
     1205    y->n = 3;
    12001206    psF32 tmpFloat = 0.0f;
    12011207
     
    13131319    if (deriv == NULL) {
    13141320        deriv = psVectorAlloc(2, PS_TYPE_F32);
     1321        deriv->n = 2;
    13151322    } else {
    13161323        PS_ASSERT_VECTOR_SIZE(deriv, 2, NAN);
     
    13651372    psS32 rcBool = false;
    13661373    psVector *tmpMaskVec = psVectorAlloc(myVector->n, PS_TYPE_U8);
     1374    tmpMaskVec->n = tmpMaskVec->nalloc;
    13671375    if (maskVector != NULL) {
    13681376        for (psS32 i = 0 ; i < myVector->n ; i++) {
     
    18501858        psArray *x = psArrayAlloc((1 + (binMax - binMin)));
    18511859        psS32 j = 0;
     1860        y->n = y->nalloc;
    18521861
    18531862        for (psS32 i = binMin ; i <= binMax ; i++) {
     
    18561865            x->n++;
    18571866            ((psVector *) x->data[j])->data.F32[0] = PS_BIN_MIDPOINT(newHistogram, i);
     1867            ((psVector *) x->data[j])->n++;
    18581868            j++;
    18591869        }
     
    18861896        psMinimization *min = psMinimizationAlloc(100, 0.01);
    18871897        psVector *params = psVectorAlloc(2, PS_TYPE_F32);
     1898        params->n = params->nalloc;
    18881899        // Initial guess for the mean ([0]) and standard dev.
    18891900        params->data.F32[0] = stats->robustMedian;
     
    20492060    // Allocate the bins, and initialize them to zero.
    20502061    newHist->nums = psVectorAlloc(n, PS_TYPE_F32);
    2051     for (i = 0; i < newHist->nums->n; i++) {
     2062    for (i = 0; i < newHist->nums->nalloc; i++) {
    20522063        newHist->nums->data.F32[i] = 0.0;
     2064        newHist->nums->n++;
    20532065    }
    20542066
     
    20942106    // then there are N-1 bins.
    20952107    newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32);
    2096     for (i = 0; i < newHist->nums->n; i++) {
     2108    for (i = 0; i < newHist->nums->nalloc; i++) {
    20972109        newHist->nums->data.F32[i] = 0.0;
     2110        newHist->nums->n++;
    20982111    }
    20992112
     
    23662379        for (i = 0; i < in->n; i++) {
    23672380            tmp->data.F32[i] = (psF32)in->data.S8[i];
     2381            tmp->n++;
    23682382        }
    23692383    } else if (in->type.type == PS_TYPE_S16) {
     
    23712385        for (i = 0; i < in->n; i++) {
    23722386            tmp->data.F32[i] = (psF32) in->data.S16[i];
     2387            tmp->n++;
    23732388        }
    23742389    } else if (in->type.type == PS_TYPE_S32) {
     
    23762391        for (i = 0; i < in->n; i++) {
    23772392            tmp->data.F32[i] = (psF32)in->data.S32[i];
     2393            tmp->n++;
    23782394        }
    23792395    } else if (in->type.type == PS_TYPE_S64) {
     
    23812397        for (i = 0; i < in->n; i++) {
    23822398            tmp->data.F32[i] = (psF32)in->data.S64[i];
     2399            tmp->n++;
    23832400        }
    23842401    } else if (in->type.type == PS_TYPE_U8) {
     
    23862403        for (i = 0; i < in->n; i++) {
    23872404            tmp->data.F32[i] = (psF32)in->data.U8[i];
     2405            tmp->n++;
    23882406        }
    23892407    } else if (in->type.type == PS_TYPE_U16) {
     
    23912409        for (i = 0; i < in->n; i++) {
    23922410            tmp->data.F32[i] = (psF32)in->data.U16[i];
     2411            tmp->n++;
    23932412        }
    23942413    } else if (in->type.type == PS_TYPE_U32) {
     
    23962415        for (i = 0; i < in->n; i++) {
    23972416            tmp->data.F32[i] = (psF32)in->data.U32[i];
     2417            tmp->n++;
    23982418        }
    23992419    } else if (in->type.type == PS_TYPE_U64) {
     
    24012421        for (i = 0; i < in->n; i++) {
    24022422            tmp->data.F32[i] = (psF32)in->data.U64[i];
     2423            tmp->n++;
    24032424        }
    24042425    } else if (in->type.type == PS_TYPE_F64) {
     
    24062427        for (i = 0; i < in->n; i++) {
    24072428            tmp->data.F32[i] = (psF32)in->data.F64[i];
     2429            tmp->n++;
    24082430        }
    24092431    } else if (in->type.type == PS_TYPE_F32) {
     
    24632485    inF32 = p_psConvertToF32((psVector *) in);
    24642486    if (inF32 == NULL) {
    2465         inF32 = (psVector *) in;
    2466         mustFreeVectorIn = 0;
    2467     }
     2487        //        printf("\n\ninF32 is NULL\n\n");
     2488        //        inF32 = (psVector *) in;
     2489        //        mustFreeVectorIn = 0;
     2490        inF32 = psVectorCopy(inF32, in, PS_TYPE_F32);
     2491        inF32->n = inF32->nalloc;
     2492        mustFreeVectorIn = 1;
     2493    }
     2494    //    else printf("\ninF32 has n=%ld, nalloc=%ld\n", inF32->n, inF32->nalloc);
    24682495    errorsF32 = p_psConvertToF32((psVector *) errors);
    24692496    if (errorsF32 == NULL) {
     
    24712498        mustFreeVectorErrors = 0;
    24722499    }
    2473 
     2500    //    inF32->n = inF32->nalloc;
     2501    //    errorsF32->n = errorsF32->nalloc;
    24742502    if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) {
    24752503        PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, stats);
Note: See TracChangeset for help on using the changeset viewer.