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.

Location:
trunk/psModules/src/objects
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/models/pmModel_GAUSS.c

    r9675 r9730  
    4545    *params_min = psVectorAlloc (7, PS_TYPE_F32);
    4646    *params_max = psVectorAlloc (7, PS_TYPE_F32);
    47     (*beta_lim)->n = (*beta_lim)->nalloc;
    48     (*params_min)->n = (*params_min)->nalloc;
    49     (*params_max)->n = (*params_max)->nalloc;
    5047
    5148    beta_lim[0][0].data.F32[PM_PAR_SKY] = 1000;
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r9621 r9730  
    4848    *params_min = psVectorAlloc (7, PS_TYPE_F32);
    4949    *params_max = psVectorAlloc (7, PS_TYPE_F32);
    50     (*beta_lim)->n = (*beta_lim)->nalloc;
    51     (*params_min)->n = (*params_min)->nalloc;
    52     (*params_max)->n = (*params_max)->nalloc;
    5350
    5451    beta_lim[0][0].data.F32[0] = 1000;
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r9676 r9730  
    6363    *params_min = psVectorAlloc (8, PS_TYPE_F32);
    6464    *params_max = psVectorAlloc (8, PS_TYPE_F32);
    65     (*beta_lim)->n = (*beta_lim)->nalloc;
    66     (*params_min)->n = (*params_min)->nalloc;
    67     (*params_max)->n = (*params_max)->nalloc;
    6865
    6966    beta_lim[0][0].data.F32[PM_PAR_SKY] = 1000;
  • trunk/psModules/src/objects/models/pmModel_SGAUSS.c

    r9621 r9730  
    6767    *params_min = psVectorAlloc (9, PS_TYPE_F32);
    6868    *params_max = psVectorAlloc (9, PS_TYPE_F32);
    69     (*beta_lim)->n = (*beta_lim)->nalloc;
    70     (*params_min)->n = (*params_min)->nalloc;
    71     (*params_max)->n = (*params_max)->nalloc;
    7269
    7370    beta_lim[0][0].data.F32[0] = 1000;
  • trunk/psModules/src/objects/pmGrowthCurve.c

    r8886 r9730  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-09-22 21:35:34 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-10-24 22:55:05 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040    growth->radius = psVectorCreate (NULL, minRadius, maxRadius, 1.0, PS_TYPE_F32);
    4141    growth->apMag  = psVectorAlloc (growth->radius->n, PS_TYPE_F32);
    42     growth->apMag->n = growth->radius->n;
    4342
    4443    // XXX may want to extend this to allow for a different refRadius;
  • trunk/psModules/src/objects/pmModel.c

    r9559 r9730  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-14 00:53:23 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6666    tmp->params  = psVectorAlloc(Nparams, PS_TYPE_F32);
    6767    tmp->dparams = psVectorAlloc(Nparams, PS_TYPE_F32);
    68     tmp->params->n = tmp->dparams->n = Nparams;
    6968
    7069    for (psS32 i = 0; i < tmp->params->n; i++) {
     
    117116    x->data.F32[0] = (psF32) (col + image->col0);
    118117    x->data.F32[1] = (psF32) (row + image->row0);
    119     x->n = 2;
    120118    psF32 tmpF;
    121119    pmModelFunc modelFunc;
     
    143141
    144142    psVector *x = psVectorAlloc(2, PS_TYPE_F32);
    145     x->n = 2;
    146143    psVector *params = model->params;
    147144    pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
  • trunk/psModules/src/objects/pmPSF.c

    r9562 r9730  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-14 00:55:43 $
     8 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    121121
    122122    psf->params = psArrayAlloc(Nparams - 4);
    123     psf->params->n = psf->params->nalloc;
    124123
    125124    // the order of the PSF parameter (X,Y) fits is determined by the
     
    166165    psVector *z  = psVectorAlloc (models->n, PS_TYPE_F64);
    167166    psVector *dz = psVectorAlloc (models->n, PS_TYPE_F64);
    168     x->n = x->nalloc;
    169     y->n = y->nalloc;
    170     z->n = z->nalloc;
    171     dz->n = dz->nalloc;
    172167
    173168    for (int i = 0; i < models->n; i++) {
     
    258253
    259254/***********************************************
    260  * this function masks the psf.ApTrend polynomial 
     255 * this function masks the psf.ApTrend polynomial
    261256 * to enable the specific subset of the coefficients
    262257 **********************************************/
  • trunk/psModules/src/objects/pmPSFtry.c

    r9594 r9730  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-10-17 02:21:03 $
     7 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-10-24 22:55:05 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7171    test->fitMag   = psVectorAlloc (sources->n, PS_TYPE_F64);
    7272    test->mask     = psVectorAlloc (sources->n, PS_TYPE_U8);
    73     test->metric->n = test->fitMag->n = test->mask->n = sources->n;
    74     test->modelEXT->n = test->modelPSF->n = sources->n;
    7573
    7674    for (int i = 0; i < test->modelEXT->n; i++) {
     
    196194    psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    197195    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
    198     flux->n = mask->n = chisq->n = psfTry->sources->n;
    199196
    200197    // write sources with models first
     
    256253    // r2rflux = radius^2 * ten(0.4*fitMag);
    257254    psVector *r2rflux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    258     r2rflux->n = psfTry->sources->n;
    259255
    260256    for (int i = 0; i < psfTry->sources->n; i++) {
  • trunk/psModules/src/objects/pmPeaks.c

    r8815 r9730  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-09-15 09:49:01 $
     8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040
    4141    if (list == NULL) {
    42         list = psArrayAlloc(100);
    43         list->n = 0;
     42        list = psArrayAllocEmpty(100);
    4443    }
    4544    psArrayAdd(list, 100, tmpPeak);
     
    6968        tmpVector->data.F32[col] = image->data.F32[row][col];
    7069    }
    71     tmpVector->n = image->numCols;
    7270    psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
    7371    return(tmpVector);
     
    194192    if (n == 1) {
    195193        psVector *tmpVector = NULL;
    196         ;
    197194        if (vector->data.F32[0] > threshold) {
    198195            tmpVector = psVectorAlloc(1, PS_TYPE_U32);
    199196            tmpVector->data.U32[0] = 0;
    200             tmpVector->n = 1;
    201197        } else {
    202198            tmpVector = psVectorAlloc(0, PS_TYPE_U32);
     
    238234    //
    239235    psVector *tmpVector = psVectorAlloc(count, PS_TYPE_U32);
    240     tmpVector->n = count;
    241236    count = 0;
    242237
     
    544539    PS_ASSERT_PTR_NON_NULL(peaks, NULL);
    545540
    546     psArray *output = psArrayAlloc (200);
    547     output->n = 0;
     541    psArray *output = psArrayAllocEmpty (200);
    548542
    549543    psTrace (".pmObjects.pmCullPeaks", 3, "list size is %ld\n", peaks->n);
  • trunk/psModules/src/objects/pmSource.c

    r9651 r9730  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-19 21:10:08 $
     8 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    294294        maxSy = clump->y * SCALE + 0.2;
    295295
    296         tmpSx = psVectorAlloc (sources->n, PS_TYPE_F32);
    297         tmpSy = psVectorAlloc (sources->n, PS_TYPE_F32);
    298         tmpSx->n = 0;
    299         tmpSy->n = 0;
     296        tmpSx = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
     297        tmpSy = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
    300298
    301299        // XXX clip sources based on flux?
     
    375373
    376374    // report stats on S/N values for star-like objects
    377     psVector *starsn = psVectorAlloc (sources->n, PS_TYPE_F32);
    378     starsn->n = 0;
     375    psVector *starsn = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
    379376
    380377    // check return status value (do these exist?)
  • trunk/psModules/src/objects/pmSourceContour.c

    r8815 r9730  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-09-15 09:49:01 $
     8 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    240240
    241241    // Allocate data for x/y pairs.
    242     psVector *xVec = psVectorAlloc(100, PS_TYPE_F32);
    243     psVector *yVec = psVectorAlloc(100, PS_TYPE_F32);
     242    psVector *xVec = psVectorAllocEmpty(100, PS_TYPE_F32);
     243    psVector *yVec = psVectorAllocEmpty(100, PS_TYPE_F32);
    244244
    245245    // First row: find the left and right end-points
     
    327327    // fprintf (stderr, "done\n");
    328328    psArray *tmpArray = psArrayAlloc(2);
    329     tmpArray->n = 2;
    330329
    331330    tmpArray->data[0] = (psPtr *) xVec;
     
    338337    pmSourceContour(src, img, level, mode): For an input subImage, and model, this
    339338    routine returns a psArray of coordinates that evaluate to the specified level.
    340     
     339 
    341340    XXX: Probably should remove the "image" argument.
    342341    XXX: What type should the output coordinate vectors consist of?  col,row?
     
    366365    psVector *xVec = psVectorAlloc(2 * source->pixels->numRows, PS_TYPE_F32);
    367366    psVector *yVec = psVectorAlloc(2 * source->pixels->numRows, PS_TYPE_F32);
    368     xVec->n = yVec->n = 2 * source->pixels->numRows;
    369367
    370368    //
     
    447445    //
    448446    psArray *tmpArray = psArrayAlloc(2);
    449     tmpArray->n = 2;
    450447
    451448    tmpArray->data[0] = (psPtr *) yVec;
  • trunk/psModules/src/objects/pmSourceFitModel.c

    r9541 r9730  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-13 22:11:02 $
     8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-10-24 22:55:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7878
    7979    // construct the coordinate and value entries
    80     psArray *x = psArrayAlloc(nPix);
    81     psVector *y = psVectorAlloc(nPix, PS_TYPE_F32);
    82     psVector *yErr = psVectorAlloc(nPix, PS_TYPE_F32);
     80    psArray *x = psArrayAllocEmpty(nPix);
     81    psVector *y = psVectorAllocEmpty(nPix, PS_TYPE_F32);
     82    psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
    8383
    8484    nPix = 0;
     
    9595
    9696            psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    97             coord->n = 2;
    9897
    9998            // Convert i/j to image space:
     
    128127    // set parameter mask based on fitting mode
    129128    paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
    130     paramMask->n = params->n;
    131129    psVectorInit (paramMask, 1);
    132130
     
    208206    if (paramMask != NULL) {
    209207        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
    210         delta->n = params->n;
    211208        psMinimizeGaussNewtonDelta(delta, params, NULL, x, y, yErr, modelFunc);
    212209        for (int i = 0; i < dparams->n; i++) {
     
    272269    onePar = psVectorAlloc (nPar, PS_DATA_F32);
    273270    oneDeriv = psVectorAlloc (nPar, PS_DATA_F32);
    274     onePar->n = oneDeriv->n = nPar;
    275271
    276272    return true;
     
    357353    psVector *params = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
    358354    psVector *dparams = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
    359     params->n = params->nalloc;
    360     dparams->n = dparams->nalloc;
    361355
    362356    pmModelLimits modelLimits = pmModelLimits_GetFunction (model->type);
     
    373367    constrain->paramMask = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_U8);
    374368    constrain->paramDelta = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
    375     constrain->paramMin->n = constrain->paramMin->nalloc;
    376     constrain->paramMax->n = constrain->paramMax->nalloc;
    377     constrain->paramMask->n = constrain->paramMask->nalloc;
    378     constrain->paramDelta->n = constrain->paramDelta->nalloc;
    379369
    380370    // set the parameter guesses and constraints for the multiple models
     
    459449
    460450    // construct the coordinate and value entries
    461     psArray *x = psArrayAlloc(nPix);
    462     psVector *y = psVectorAlloc(nPix, PS_TYPE_F32);
    463     psVector *yErr = psVectorAlloc(nPix, PS_TYPE_F32);
     451    psArray *x = psArrayAllocEmpty(nPix);
     452    psVector *y = psVectorAllocEmpty(nPix, PS_TYPE_F32);
     453    psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
    464454
    465455    nPix = 0;
     
    475465            }
    476466            psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    477             coord->n = 2;
    478467
    479468            // Convert i/j to image space:
     
    534523    if (constrain->paramMask != NULL) {
    535524        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
    536         delta->n = params->n;
    537525        psMinimizeGaussNewtonDelta(delta, params, NULL, x, y, yErr, pmModelFitSet);
    538526        for (int i = 0; i < dparams->n; i++) {
  • trunk/psModules/src/objects/pmSourceIO_CMF.c

    r9653 r9730  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-10-19 21:16:49 $
     5 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-10-24 22:55:05 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050    float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
    5151
    52     table = psArrayAlloc (sources->n);
    53     table->n = 0;
     52    table = psArrayAllocEmpty (sources->n);
    5453
    5554    for (i = 0; i < sources->n; i++) {
     
    130129
    131130    psArray *sources = psArrayAlloc (table->n);
    132     sources->n = table->n;
    133131
    134132    // convert the table to the pmSource entries
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r9594 r9730  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-10-17 02:21:03 $
     5 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-10-24 22:55:05 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    241241    pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
    242242    psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    243     coord->n = 2;
    244243
    245244    psVector *params = model->params;
Note: See TracChangeset for help on using the changeset viewer.