IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9730 for trunk/psLib/src/math


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.

Location:
trunk/psLib/src/math
Files:
8 edited

Legend:

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

    r9556 r9730  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-10-14 00:15:47 $
     12 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-10-24 22:52:56 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    163163    psImage  *Alpha  = psImageAlloc (params->n, params->n, PS_TYPE_F64);
    164164    psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
    165     beta->n = beta->nalloc;
    166165    psVector *Params = psVectorAlloc(params->n, PS_TYPE_F64);
    167     Params->n = Params->nalloc;
    168166    psVector *dy     = NULL;
    169167    psBool rc = true;
     
    175173    } else {
    176174        dy = psVectorAlloc(y->n, PS_TYPE_F32);
    177         dy->n = dy->nalloc;
    178175        psVectorInit(dy, 1.0);
    179176    }
     
    246243    psF64 ymodel;
    247244    psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
    248     deriv->n = deriv->nalloc;
    249245
    250246    // zero alpha and beta for summing below
     
    380376    psImage *Alpha   = psImageAlloc(params->n, params->n, PS_TYPE_F64);
    381377    psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
    382     beta->n = beta->nalloc;
    383378    psVector *Beta   = psVectorAlloc(params->n, PS_TYPE_F64);
    384     beta->n = beta->nalloc;
    385379    psVector *Params = psVectorAlloc(params->n, PS_TYPE_F32);
    386     Params->n = Params->nalloc;
    387380    psVector *dy     = NULL;
    388381    psF64 Chisq = 0.0;
     
    398391    } else {
    399392        dy = psVectorAlloc(y->n, PS_TYPE_F32);
    400         dy->n = dy->nalloc;
    401393        psVectorInit(dy, 1.0);
    402394    }
  • trunk/psLib/src/math/psMinimizePolyFit.c

    r9640 r9730  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-10-19 02:57:18 $
     12 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-10-24 22:52:56 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4646#define PS_VECTOR_GEN_CHEBY_INDEX(VEC, SIZE, TYPE) \
    4747VEC = psVectorAlloc(SIZE, TYPE); \
    48 VEC->n = VEC->nalloc; \
    4948if (TYPE == PS_TYPE_F64) { \
    5049    for (psS32 i = 0 ; i < SIZE ; i++) { \
     
    9392    if (sums == NULL) {
    9493        sums = psVectorAlloc(nSum, PS_TYPE_F64);
    95         sums->n = sums->nalloc;
    9694    } else if (nSum > sums->n) {
    9795        sums = psVectorRealloc(sums, nSum);
    98         sums->n = sums->nalloc;
     96        sums->n = nSum;
    9997    }
    10098
     
    333331    psImage *A = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix
    334332    psVector *B = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector
    335     B->n = numTerms;
    336333    psImageInit(A, 0.0);
    337334    psVectorInit(B, 0.0);
     
    509506    psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
    510507    psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
    511     B->n = B->nalloc;
    512508
    513509    // Initialize data structures.
     
    805801    psVector *fit   = NULL;
    806802    psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
    807     resid->n = resid->nalloc;
    808803
    809804    // eventual expansion: user supplies one of various stats option pairs,
     
    976971    psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
    977972    psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
    978     B->n = B->nalloc;
    979973
    980974    // Initialize data structures.
     
    12561250    }
    12571251    psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
    1258     resid->n = resid->nalloc;
    12591252
    12601253    // eventual expansion: user supplies one of various stats option pairs,
     
    14341427    psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
    14351428    psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
    1436     B->n = B->nalloc;
    14371429
    14381430    // Initialize data structures.
     
    17901782    psVector *fit   = NULL;
    17911783    psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
    1792     resid->n = resid->nalloc;
    17931784
    17941785    // eventual expansion: user supplies one of various stats option pairs,
     
    19671958    psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
    19681959    psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
    1969     B->n = B->nalloc;
    19701960
    19711961    // Initialize data structures.
     
    23682358    psVector *fit   = NULL;
    23692359    psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
    2370     resid->n = resid->nalloc;
    23712360
    23722361    // eventual expansion: user supplies one of various stats option pairs,
  • trunk/psLib/src/math/psMinimizePowell.c

    r9540 r9730  
    1111 *  NOTE: XXX: The SDR is silent about data types.  F32 is implemented here.
    1212 *
    13  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-10-13 22:04:58 $
     13 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-10-24 22:52:56 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    549549                ((psVector *) (v->data[i]))->data.F32[j] = 0.0;
    550550            }
    551             ((psVector *)(v->data[i]))->n++;
    552         }
    553         v->n++;
     551        }
    554552    }
    555553
  • trunk/psLib/src/math/psPolynomial.c

    r9540 r9730  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.151 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-10-13 22:04:58 $
     9*  @version $Revision: 1.152 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-10-24 22:52:56 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    266266        // General case where the Chebyshev poly has 2 or more terms.
    267267        d = psVectorAlloc(nTerms, PS_TYPE_F64);
    268         d->n = d->nalloc;
    269268        if(poly->mask[nTerms-1] == 0) {
    270269            d->data.F64[nTerms-1] = poly->coeff[nTerms-1];
     
    571570    psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
    572571    return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma)));
    573 }
    574 
    575 /*****************************************************************************
    576     p_psGaussianDev()
    577  This private routine (formerly a psLib API routine) creates a psVector of the
    578  specified size and type F32 and fills it with a random Gaussian distribution
    579  of numbers with the specified mean and sigma.
    580  
    581 XXX: It's possible to have a different seed everytime.  However, for now,
    582 for testability, we use a common seed.
    583  *****************************************************************************/
    584 #define PS_XXX_GAUSSIAN_SEED 1995
    585 psVector* p_psGaussianDev(psF32 mean,
    586                           psF32 sigma,
    587                           unsigned int Npts)
    588 {
    589     PS_ASSERT_INT_NONNEGATIVE(Npts, NULL);
    590 
    591     //    psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, p_psRandomGetSystemSeed());
    592     psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);
    593     psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32);
    594     for (unsigned int i = 0; i < Npts; i++) {
    595         gauss->data.F32[i] = mean + p_psRandomGaussian(r, sigma);
    596         gauss->n++;
    597     }
    598     psFree(r);
    599 
    600     return(gauss);
    601572}
    602573
     
    808779        for (unsigned int i=0;i<x->n;i++) {
    809780            tmp->data.F64[i] = psPolynomial1DEval(poly, x->data.F64[i]);
    810             tmp->n++;
    811781        }
    812782        break;
     
    815785        for (unsigned int i=0;i<x->n;i++) {
    816786            tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]);
    817             tmp->n++;
    818787        }
    819788        break;
     
    877846        for (unsigned int i=0; i<vecLen; i++) {
    878847            tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]);
    879             tmp->n++;
    880848        }
    881849        break;
     
    892860        for (unsigned int i=0; i<vecLen; i++) {
    893861            tmp->data.F64[i] = psPolynomial2DEval(poly,x->data.F64[i],y->data.F64[i]);
    894             tmp->n++;
    895862        }
    896863        break;
     
    959926            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
    960927                                                  y->data.F32[i], z->data.F32[i]);
    961             tmp->n++;
    962928        }
    963929    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
     
    966932            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
    967933                                                  y->data.F32[i], z->data.F64[i]);
    968             tmp->n++;
    969934        }
    970935    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    973938            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
    974939                                                  y->data.F64[i], z->data.F32[i]);
    975             tmp->n++;
    976940        }
    977941    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    980944            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
    981945                                                  y->data.F64[i], z->data.F64[i]);
    982             tmp->n++;
    983946        }
    984947    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    987950            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
    988951                                                  y->data.F32[i], z->data.F32[i]);
    989             tmp->n++;
    990952        }
    991953    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    994956            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
    995957                                                  y->data.F32[i], z->data.F64[i]);
    996             tmp->n++;
    997958        }
    998959    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    1001962            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
    1002963                                                  y->data.F64[i], z->data.F32[i]);
    1003             tmp->n++;
    1004964        }
    1005965    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    1008968            tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
    1009969                                                  y->data.F64[i], z->data.F64[i]);
    1010             tmp->n++;
    1011970        }
    1012971    }
     
    10791038            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    10801039                                                  y->data.F32[i], z->data.F32[i], t->data.F32[i]);
    1081             tmp->n++;
    10821040        }
    10831041    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
     
    10861044            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    10871045                                                  y->data.F32[i], z->data.F32[i], t->data.F64[i]);
    1088             tmp->n++;
    10891046        }
    10901047    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
     
    10931050            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    10941051                                                  y->data.F32[i], z->data.F64[i], t->data.F32[i]);
    1095             tmp->n++;
    10961052        }
    10971053    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
     
    11001056            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    11011057                                                  y->data.F32[i], z->data.F64[i], t->data.F64[i]);
    1102             tmp->n++;
    11031058        }
    11041059    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    11071062            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    11081063                                                  y->data.F64[i], z->data.F32[i], t->data.F32[i]);
    1109             tmp->n++;
    11101064        }
    11111065    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    11141068            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    11151069                                                  y->data.F64[i], z->data.F32[i], t->data.F64[i]);
    1116             tmp->n++;
    11171070        }
    11181071    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    11211074            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    11221075                                                  y->data.F64[i], z->data.F64[i], t->data.F32[i]);
    1123             tmp->n++;
    11241076        }
    11251077    } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
     
    11281080            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
    11291081                                                  y->data.F64[i], z->data.F64[i], t->data.F64[i]);
    1130             tmp->n++;
    11311082        }
    11321083    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    11351086            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11361087                                                  y->data.F32[i], z->data.F32[i], t->data.F32[i]);
    1137             tmp->n++;
    11381088        }
    11391089    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    11421092            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11431093                                                  y->data.F32[i], z->data.F32[i], t->data.F64[i]);
    1144             tmp->n++;
    11451094        }
    11461095    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    11491098            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11501099                                                  y->data.F32[i], z->data.F64[i], t->data.F32[i]);
    1151             tmp->n++;
    11521100        }
    11531101    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
     
    11561104            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11571105                                                  y->data.F32[i], z->data.F64[i], t->data.F64[i]);
    1158             tmp->n++;
    11591106        }
    11601107    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    11631110            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11641111                                                  y->data.F64[i], z->data.F32[i], t->data.F32[i]);
    1165             tmp->n++;
    11661112        }
    11671113    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    11701116            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11711117                                                  y->data.F64[i], z->data.F32[i], t->data.F64[i]);
    1172             tmp->n++;
    11731118        }
    11741119    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    11771122            tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
    11781123                                                  y->data.F64[i], z->data.F64[i], t->data.F32[i]);
    1179             tmp->n++;
    11801124        }
    11811125    } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
     
    11851129                                                  y->data.F64[i], z->data.F64[i],
    11861130                                                  t->data.F64[i]);
    1187             tmp->n++;
    11881131        }
    11891132    }
  • trunk/psLib/src/math/psPolynomial.h

    r7766 r9730  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-30 02:20:06 $
     13 *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-10-24 22:52:56 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4545    float sigma,                       ///< Standard deviation for the Gaussian
    4646    bool normal                        ///< Indicates whether result should be normalized
    47 );
    48 
    49 /** Produce a vector of random numbers from a Gaussian distribution with
    50  *  the specified mean and sigma
    51  *
    52  *  @return psVector*    vector of random numbers
    53  *
    54  */
    55 psVector* p_psGaussianDev(
    56     psF32 mean,                        ///< The mean of the Gaussian
    57     psF32 sigma,                       ///< The sigma of the Gaussian
    58     unsigned int Npts                  ///< The size of the vector
    5947);
    6048
  • trunk/psLib/src/math/psSparse.c

    r8627 r9730  
    3535    psMemSetDeallocator(sparse, (psFreeFunc)sparseFree);
    3636
    37     sparse->Aij = psVectorAlloc(Nelem, PS_DATA_F32);
    38     sparse->Si  = psVectorAlloc(Nelem, PS_DATA_S32);
    39     sparse->Sj  = psVectorAlloc(Nelem, PS_DATA_S32);
    40 
    41     sparse->Aij->n = 0;
    42     sparse->Si->n  = 0;
    43     sparse->Sj->n  = 0;
     37    sparse->Aij = psVectorAllocEmpty(Nelem, PS_DATA_F32);
     38    sparse->Si  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
     39    sparse->Sj  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
     40
    4441    sparse->Nelem = 0;
    4542
    4643    sparse->Bfj = psVectorAlloc(Nrows, PS_DATA_F32);
    4744    sparse->Qii = psVectorAlloc(Nrows, PS_DATA_F32);
    48     sparse->Bfj->n = Nrows;
    49     sparse->Qii->n = Nrows;
    5045
    5146    sparse->Nrows = Nrows;
     
    157152    // temporary storage for intermediate results
    158153    psVector *dQ = psVectorAlloc(output->n, PS_DATA_F32);
    159     dQ->n = output->n;
    160154
    161155    for (int j = 0; j < Niter; j++) {
     
    197191    psVector *tSi  = psVectorAlloc(Nelem, PS_DATA_S32);
    198192    psVector *tSj  = psVectorAlloc(Nelem, PS_DATA_S32);
    199     tAij->n = tSi->n = tSj->n = Nelem;
    200193
    201194    for (int i = 0; i < Nelem; i++) {
  • trunk/psLib/src/math/psSpline.c

    r9540 r9730  
    66*  This file contains the routines that allocate, free, and evaluate splines.
    77*
    8 *  @version $Revision: 1.155 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2006-10-13 22:04:58 $
     8*  @version $Revision: 1.156 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2006-10-24 22:52:56 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    239239            for (psS32 i = 0 ; i < x->n ; i++) {
    240240                spline->knots->data.F32[i] = x->data.F32[i];
    241                 spline->knots->n++;
    242241            }
    243242        } else if (x->type.type == PS_TYPE_F64) {
    244243            for (psS32 i = 0 ; i < x->n ; i++) {
    245244                spline->knots->data.F32[i] = (psF32) x->data.F64[i];
    246                 spline->knots->n++;
    247245            }
    248246        }
     
    250248        for (psS32 i = 0 ; i < y->n ; i++) {
    251249            spline->knots->data.F32[i] = (psF32) i;
    252             spline->knots->n++;
    253250        }
    254251    }
     
    415412        for (psS32 i=0;i<x->n;i++) {
    416413            tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
    417             tmpVector->n++;
    418414        }
    419415    } else if (x->type.type == PS_TYPE_F64) {
    420416        for (psS32 i=0;i<x->n;i++) {
    421417            tmpVector->data.F32[i] = psSpline1DEval(spline, (psF32) x->data.F64[i]);
    422             tmpVector->n++;
    423418        }
    424419    }
  • 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.