IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9730


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
Files:
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r9540 r9730  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.125 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-10-13 22:04:58 $
     12*  @version $Revision: 1.126 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-10-24 22:52:55 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    795795    psVector *xOut = psVectorAlloc(numCoords, PS_TYPE_F64);
    796796    psVector *yOut = psVectorAlloc(numCoords, PS_TYPE_F64);
    797     for (psS32 g = 0; g < numCoords; g++) {
     797    for (int g = 0; g < numCoords; g++) {
    798798        xIn->data.F64[g] = ((psPlane *) source->data[g])->x;
    799         xIn->n++;
    800799        yIn->data.F64[g] = ((psPlane *) source->data[g])->y;
    801         yIn->n++;
    802800        xOut->data.F64[g] = ((psPlane *) dest->data[g])->x;
    803         xOut->n++;
    804801        yOut->data.F64[g] = ((psPlane *) dest->data[g])->y;
    805         yOut->n++;
    806802    }
    807803
  • trunk/psLib/src/db/psDB.c

    r9690 r9730  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-10-21 01:09:37 $
     14 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-24 22:52:55 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    395395    // then reset n to 0 so elements are added from the beginning of
    396396    // the array
    397     column = psArrayAlloc(rowCount);
    398     column->n = 0;
     397    column = psArrayAllocEmpty(rowCount);
    399398
    400399    // Fetch each result
     
    459458
    460459    psVector *column = psVectorAlloc(stringColumn->n, type);
    461     //    column->n = column->nalloc;
    462460
    463461    // conversion functions are a portability issue
    464462    switch (type) {
    465463    case PS_TYPE_S8:
    466         column->n = column->nalloc;
    467464        PS_STR_ARRAY_TO_PTYPE(column->data.S8, stringColumn, atoi, psS8, PS_TYPE_S8);
    468465        break;
    469466    case PS_TYPE_S16:
    470         column->n = column->nalloc;
    471467        PS_STR_ARRAY_TO_PTYPE(column->data.S16, stringColumn, atoi, psS16, PS_TYPE_S16);
    472468        break;
    473469    case PS_TYPE_S32:
    474         column->n = column->nalloc;
    475470        PS_STR_ARRAY_TO_PTYPE(column->data.S32, stringColumn, atoi, psS32, PS_TYPE_S32);
    476471        break;
    477472    case PS_TYPE_S64:
    478         column->n = column->nalloc;
    479473        PS_STR_ARRAY_TO_PTYPE(column->data.S64, stringColumn, atoll, psS64, PS_TYPE_S64);
    480474        break;
    481475    case PS_TYPE_U8:
    482         column->n = column->nalloc;
    483476        PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
    484477        break;
    485478    case PS_TYPE_U16:
    486         column->n = column->nalloc;
    487479        PS_STR_ARRAY_TO_PTYPE(column->data.U16, stringColumn, atoi, psU16, PS_TYPE_U16);
    488480        break;
    489481    case PS_TYPE_U32:
    490         column->n = column->nalloc;
    491482        PS_STR_ARRAY_TO_PTYPE(column->data.U32, stringColumn, atoi, psU32, PS_TYPE_U32);
    492483        break;
    493484    case PS_TYPE_U64:
    494         column->n = column->nalloc;
    495485        PS_STR_ARRAY_TO_PTYPE(column->data.U64, stringColumn, atoll, psU64, PS_TYPE_U64);
    496486        break;
    497487    case PS_TYPE_F32:
    498         column->n = column->nalloc;
    499488        PS_STR_ARRAY_TO_PTYPE(column->data.F32, stringColumn, atof, psF32, PS_TYPE_F32);
    500489        break;
    501490    case PS_TYPE_F64:
    502         column->n = column->nalloc;
    503491        PS_STR_ARRAY_TO_PTYPE(column->data.F64, stringColumn, atof, psF64, PS_TYPE_F64);
    504492        break;
    505493    case PS_TYPE_C32:
    506494        // this is a bogus SQL type
    507         column->n = column->nalloc;
    508495        PS_STR_ARRAY_TO_PTYPE(column->data.C32, stringColumn, atof, psC32, PS_TYPE_C32);
    509496        break;
     
    514501    case PS_TYPE_BOOL:
    515502        // valid for psVector?
    516         column->n = column->nalloc;
    517503        PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
    518504        break;
     
    567553
    568554    // Create array to store single row
    569     psArray *rowSet = psArrayAlloc(1);
    570     rowSet->n = 0;
     555    psArray *rowSet = psArrayAllocEmpty(1);
    571556    psArrayAdd(rowSet, 0, (psPtr)row);
    572557
     
    697682    }
    698683
    699     psArray *rowData = psArrayAlloc(1);
     684    psArray *rowData = psArrayAllocEmpty(1);
    700685    psArrayAdd(rowData, 0, values);
    701686    long rowsAffected = p_psDBRunQueryPrepared(dbh, rowData, query);
     
    966951    // then reset n to 0 so elements are added from the beginning of
    967952    // the array
    968     resultSet = psArrayAlloc(rowCount);
     953    resultSet = psArrayAllocEmpty(rowCount);
    969954
    970955    field = mysql_fetch_fields(result);
     
    13041289    // Reset iterator to head of list
    13051290    psListIteratorSet(cursor, 0);
    1306     psArray *pKeys = psArrayAlloc(1);
     1291    psArray *pKeys = psArrayAllocEmpty(1);
    13071292    while ((item = psListGetAndIncrement(cursor))) {
    13081293        if (strstr(item->comment, "Primary Key")) {
  • trunk/psLib/src/fits/psFitsImage.c

    r9538 r9730  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-10-13 21:13:47 $
     9 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-10-24 22:52:55 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    519519    if (nAxis == 2) {
    520520        psArray *images = psArrayAlloc(1); // Single image plane
    521         images->n = 1;
    522521        images->data[0] = psFitsReadImage(fits, region, 0);
    523522        return images;
     
    533532
    534533        psArray *images = psArrayAlloc(nAxes[2]); // Array of image planes
    535         images->n = nAxes[2];
    536534        for (int i = 0; i < nAxes[2]; i++) {
    537535            images->data[i] = psFitsReadImage(fits, region, i);
  • trunk/psLib/src/fits/psFitsTable.c

    r8627 r9730  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-08-26 04:34:28 $
     9 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-10-24 22:52:55 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    237237        result->data[row] = psAlloc((width+1)*sizeof(char));
    238238    }
    239     result->n = numRows;
    240239
    241240    fits_read_col_str(fits->fd,
     
    319318
    320319    psVector* result = psVectorAlloc(numRows, p_psFitsTypeFromCfitsio(typecode));
    321     result->n = numRows;
    322320
    323321    fits_read_col(fits->fd,
     
    389387        psTrace("psLib.fits",5,"Reading row %i of %li\n",row, numRows);
    390388        table->data[row] = psFitsReadTableRow(fits,row);
    391         table->n++;
    392389    }
    393390
     
    564561    psArray *columnNames = psArrayAlloc(numColumns); // Array of column names, for cfitsio
    565562    psArray *columnTypes = psArrayAlloc(numColumns); // Array of column types, for cfitsio
    566     columnNames->n = numColumns;
    567     columnTypes->n = numColumns;
    568563    psMetadataIterator *colSpecsIter = psMetadataIteratorAlloc(colSpecs, PS_LIST_HEAD, NULL); // Iterator
    569564    psMetadataItem *colSpecItem;        // Column specification item, from iteration
     
    644639            size_t dataSize = PSELEMTYPE_SIZEOF(spec->type); // Size (in bytes) of this type
    645640            psVector *columnData = psVectorAlloc(table->n, spec->type); // The raw row data, to be written
    646             columnData->n = table->n;
    647641            psVectorInit(columnData, 0);
    648642            for (long i = 0; i < table->n; i++) {
     
    667661            case PS_DATA_STRING: {
    668662                    psArray *strings = psArrayAlloc(table->n); // Array of strings
    669                     strings->n = table->n;
    670663                    for (long i = 0; i < table->n; i++) {
    671664                        psMetadata *row = table->data[i]; // The row of interest
  • trunk/psLib/src/imageops/psImageBackground.c

    r8978 r9730  
    3636    int Npixels = nx*ny;                // Total number of pixels
    3737
    38     psVector *values = psVectorAlloc(Nsubset, PS_TYPE_F32); // Vector containing subsample
     38    psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample
    3939
    4040    // Minimum and maximum values
  • trunk/psLib/src/imageops/psImageConvolve.c

    r9538 r9730  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-10-13 21:13:48 $
     7 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-10-24 22:52:55 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    505505        /* generate normalized gaussian */ \
    506506        psVector *gaussnorm = psVectorAlloc(Npixel, PS_TYPE_##TYPE); \
    507         gaussnorm->n = gaussnorm->nalloc; \
    508507        { \
    509508            double sum = 0.0; \
     
    522521        { \
    523522            psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \
    524             calculation->n = calculation->nalloc; \
    525523            for (int j = 0; j < Ny; j++) { \
    526524                ps##TYPE *vi = image->data.TYPE[j]; \
     
    573571        /* Smooth in Y direction */ \
    574572        psArray *rows = psArrayAlloc(Nrange); \
    575         rows->n = Nrange; \
    576573        /* Smooth the first Nrange pixels, with renorm */ \
    577574        int yMax = PS_MIN(Nrange, Ny); \
     
    579576        for (int j = 0; j < yMax; j++) { \
    580577            psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \
    581             calculation->n = calculation->nalloc; \
    582578            /* Zero the output row */ \
    583579            memset(calculation->data.TYPE, 0, Nx*sizeof(ps##TYPE)); \
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r8232 r9730  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-08-08 23:32:23 $
     12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-10-24 22:52:55 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8080    }
    8181
    82     vec = psVectorAlloc(scale * scale, in->type.type);
     82    vec = psVectorAllocEmpty(scale * scale, in->type.type);
    8383
    8484    if (mask != NULL) {
     
    9393            return NULL;
    9494        }
    95         maskVec = psVectorAlloc(scale * scale, PS_TYPE_MASK);
    96         maskVec->n = maskVec->nalloc;
     95        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
    9796        maskData = maskVec->data.PS_TYPE_MASK_DATA;
    9897    }
     
    134133                } \
    135134                vec->n = n; \
     135                maskVec->n = n; \
    136136                myStats = psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
    137137                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r8627 r9730  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-08-26 04:34:28 $
     10 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-10-24 22:52:55 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818
    1919#include "psMemory.h"
     20#include "psVector.h"
    2021#include "psImagePixelExtract.h"
    2122#include "psError.h"
     
    392393    if (direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG) {
    393394        psVector* imgVec = psVectorAlloc(numRows, type);
    394         imgVec->n = imgVec->nalloc;
    395395        psVector* maskVec = NULL;
    396396        psMaskType* maskData = NULL;
     
    417417        if (mask != NULL) {
    418418            maskVec = psVectorAlloc(numRows, mask->type.type);
    419             maskVec->n = maskVec->nalloc;
    420419        }
    421420        #define PSIMAGE_CUT_VERTICAL(TYPE) \
     
    855854        // n.b. alloc enough for the data by making the vectors slightly larger
    856855        // than the area of the region of interest.
    857         buffer[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]),
    858                                     input->type.type);
    859         buffer[lcv]->n = 0;
     856        buffer[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
     857                                         input->type.type);
    860858
    861859        bufferMask[lcv] = NULL;
    862860        if (mask != NULL) {
    863             bufferMask[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]),
    864                                             PS_TYPE_MASK);
    865             bufferMask[lcv]->n = 0;
     861            bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
     862                                                 PS_TYPE_MASK);
    866863        }
    867864    }
  • trunk/psLib/src/imageops/psImageStats.c

    r8627 r9730  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.100 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-08-26 04:34:28 $
     11 *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-10-24 22:52:55 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7676
    7777        junkData = psVectorAlloc(numRows*numCols, in->type.type);
    78         junkData->n = junkData->nalloc;
    7978
    8079        psU8* data = junkData->data.U8;
     
    10099
    101100            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    102             junkMask->n = junkMask->nalloc;
    103101
    104102            psU8* data = junkMask->data.U8;
     
    149147
    150148        junkData = psVectorAlloc(numRows*numCols, in->type.type);
    151         junkData->n = junkData->nalloc;
    152149
    153150        psU8* data = junkData->data.U8;
     
    173170
    174171            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    175             junkMask->n = junkMask->nalloc;
    176172
    177173            psU8* data = junkMask->data.U8;
     
    592588        return -1;
    593589    }/* else if (col0 == col1 && row0 == row1) {
    594                                                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    595                                                         "Invalid psRegion specified.  Region contains only 1 pixel.\n");
    596                                                 return -1;
    597                                             }
    598                                         */
     590                                                    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     591                                                            "Invalid psRegion specified.  Region contains only 1 pixel.\n");
     592                                                    return -1;
     593                                                }
     594                                            */
    599595    x0 = col0;
    600596    x1 = col1;
  • trunk/psLib/src/jpeg/psImageJpeg.c

    r8977 r9730  
    3333    map->blue  = psVectorAlloc(256, PS_TYPE_U8);
    3434    map->green = psVectorAlloc(256, PS_TYPE_U8);
    35 
    36     map->red->n = 256;
    37     map->blue->n = 256;
    38     map->green->n = 256;
    3935
    4036    return map;
  • 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.
  • trunk/psLib/src/mathtypes/psVector.c

    r9554 r9730  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2006-10-14 00:12:39 $
     11*  @version $Revision: 1.87 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2006-10-24 22:52:56 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6868
    6969
    70 psVector* psVectorAlloc(long nalloc,
    71                         psElemType type)
    72 {
    73     psVector* psVec = NULL;
    74     psS32 elementSize = 0;
    75 
    76     elementSize = PSELEMTYPE_SIZEOF(type);
     70// Allocate a psVector; does not set vector->n (left to the caller)
     71static psVector *vectorAlloc(long nalloc, // Number of elements to allocate
     72                             psElemType type // Type of elements
     73                            )
     74{
     75    int elementSize = PSELEMTYPE_SIZEOF(type); // Size, in bytes, of element
    7776    if (elementSize < 1) {
    7877        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     
    8180    }
    8281
    83 
    8482    // Create vector struct
    85     psVec = (psVector* ) psAlloc(sizeof(psVector));
    86     psMemSetDeallocator(psVec, (psFreeFunc) vectorFree);
    87 
    88     psVec->type.dimen = PS_DIMEN_VECTOR;
    89     psVec->type.type = type;
    90     P_PSVECTOR_SET_NALLOC(psVec,nalloc);
    91     //    psVec->n = nalloc;
    92     psVec->n = 0;
     83    psVector *vector = (psVector*) psAlloc(sizeof(psVector));
     84    psMemSetDeallocator(vector, (psFreeFunc) vectorFree);
     85
     86    vector->type.dimen = PS_DIMEN_VECTOR;
     87    vector->type.type = type;
     88    P_PSVECTOR_SET_NALLOC(vector, nalloc);
    9389
    9490    // Create vector data array
    95     psVec->data.U8 = psAlloc(nalloc * elementSize);
    96 
    97     return psVec;
     91    vector->data.U8 = psAlloc(nalloc * elementSize);
     92
     93    return vector;
     94}
     95
     96psVector* psVectorAlloc(long nalloc,
     97                        psElemType type)
     98{
     99    psVector *vector = vectorAlloc(nalloc, type);
     100    if (!vector) {
     101        return NULL;
     102    }
     103    vector->n = nalloc;
     104    return vector;
     105}
     106
     107psVector* psVectorAllocEmpty(long nalloc,
     108                             psElemType type)
     109{
     110    psVector *vector = vectorAlloc(nalloc, type);
     111    if (!vector) {
     112        return NULL;
     113    }
     114    vector->n = 0;
     115    return vector;
    98116}
    99117
  • trunk/psLib/src/mathtypes/psVector.h

    r9553 r9730  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-10-14 00:07:13 $
     13 *  @version $Revision: 1.59 $ $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
     
    7474        ;
    7575
    76 /** Allocate a vector.
     76/** Allocate a vector, with length set to number allocated
    7777 *
    7878 *  Uses psLib memory allocation functions to create a vector collection of
     
    8282 */
    8383psVector* psVectorAlloc(
     84    long nalloc,                       ///< Total number of elements to make available.
     85    psElemType type                    ///< Type of data to be held by vector.
     86);
     87
     88/** Allocate a vector, with length set to zero
     89 *
     90 *  Uses psLib memory allocation functions to create a vector collection of
     91 *  data as defined by the psType type.
     92 *
     93 * @return psVector*    Pointer to psVector.
     94 */
     95psVector* psVectorAllocEmpty(
    8496    long nalloc,                       ///< Total number of elements to make available.
    8597    psElemType type                    ///< Type of data to be held by vector.
  • trunk/psLib/src/sys/psError.c

    r9623 r9730  
    1111 *  @author Eric Van Alst, MHPCC
    1212 *
    13  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-10-18 15:26:33 $
     13 *  @version $Revision: 1.41 $ $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
     
    8484    if ((errorStack = pthread_getspecific(errorStack_key)) == NULL) {
    8585        // allocate the error stack
    86         errorStack = psArrayAlloc(MAX_ERROR_STACK_SIZE);
     86        errorStack = psArrayAllocEmpty(MAX_ERROR_STACK_SIZE);
    8787        p_psMemSetPersistent(errorStack, true);
    8888        p_psMemSetPersistent(errorStack->data, true);
  • trunk/psLib/src/types/psArray.c

    r9543 r9730  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-10-13 22:24:29 $
     11 *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-10-24 22:52:56 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4949}
    5050
     51// Allocate an array, deliberately leave size unset.
     52static psArray *arrayAlloc(long nalloc)
     53{
     54    if (nalloc < 0) {
     55        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     56                "Can't allocate a psArray of negative size.");
     57        return NULL;
     58    }
     59
     60    // Create vector struct
     61    psArray *array = (psArray*)psAlloc(sizeof(psArray));
     62    psMemSetDeallocator(array, (psFreeFunc)arrayFree);
     63
     64    P_PSARRAY_SET_NALLOC(array, nalloc);
     65    // Create vector data array
     66    array->data = psAlloc(nalloc * sizeof(psPtr));
     67    memset(array->data, 0, sizeof(void*) * nalloc);  //set the initial values of data to NULL
     68
     69    return array;
     70}
    5171
    5272/*****************************************************************************
     
    5575psArray* psArrayAlloc(long nalloc)
    5676{
    57     if (nalloc < 0) {
    58         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    59                 "Can't allocate a psArray of negative size.");
    60         return NULL;
    61     }
    62     psArray* psArr = NULL;
    63 
    64     // Create vector struct
    65     psArr = (psArray* ) psAlloc(sizeof(psArray));
    66     psMemSetDeallocator(psArr, (psFreeFunc) arrayFree);
    67 
    68     P_PSARRAY_SET_NALLOC(psArr,nalloc);
    69     psArr->n = 0;  //set the initial number of elements in use to 0
    70     // Create vector data array
    71     psArr->data = psAlloc(nalloc * sizeof(psPtr));
    72     memset(psArr->data, 0, sizeof(void*) * nalloc);  //set the initial values of data to NULL
    73 
    74     return psArr;
     77    psArray *array = arrayAlloc(nalloc);
     78    if (!array) {
     79        return NULL;
     80    }
     81    array->n = nalloc;
     82    return array;
     83}
     84
     85psArray* psArrayAllocEmpty(long nalloc)
     86{
     87    psArray *array = arrayAlloc(nalloc);
     88    if (!array) {
     89        return NULL;
     90    }
     91    array->n = 0;
     92    return array;
    7593}
    7694
  • trunk/psLib/src/types/psArray.h

    r9543 r9730  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-10-13 22:24:29 $
     13 *  @version $Revision: 1.43 $ $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
     
    6060
    6161
    62 /** Allocate an array.
     62/** Allocate an array, set the length to the number of allocated elements
    6363 *
    6464 * Uses psLib memory allocation functions to create an array collection of
     
    6969 */
    7070psArray* psArrayAlloc(
     71    long nalloc                        ///< Total number of elements to make available.
     72);
     73
     74/** Allocate an array, set the length to zero.
     75 *
     76 * Uses psLib memory allocation functions to create an array collection of
     77 * data
     78 *
     79 * @return psArray* : Pointer to psArray.
     80 *
     81 */
     82psArray* psArrayAllocEmpty(
    7183    long nalloc                        ///< Total number of elements to make available.
    7284);
  • trunk/psLib/src/types/psHash.c

    r9538 r9730  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-10-13 21:13:48 $
     14*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-10-24 22:52:56 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    433433
    434434    psArray* result = psArrayAlloc(nElements);
    435     result->n = nElements;
    436435
    437436    // now fill in the array with the hash hash's data
  • trunk/psLib/src/types/psList.c

    r9538 r9730  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-13 21:13:48 $
     8 *  @version $Revision: 1.56 $ $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
     
    2525#define ITER_INIT_HEAD ((psPtr )1)         // next iteration should return head
    2626#define ITER_INIT_TAIL ((psPtr )2)         // next iteration should return tail
     27
     28#define INITIAL_NUM_ITERATORS 16        // Initial number of iterators to create
    2729
    2830// private functions.
     
    125127    list->n = 0;
    126128    list->head = list->tail = NULL;
    127     list->iterators = psArrayAlloc(16);
    128     list->iterators->n = 0;
     129    list->iterators = psArrayAllocEmpty(INITIAL_NUM_ITERATORS);
    129130
    130131    // create a default iterator
     
    564565psArray* psListToArray(const psList* list)
    565566{
    566     psListElem* ptr;
    567     psU32 n;
    568     psArray* arr;
    569 
    570     if (list == NULL) {
    571         return NULL;
    572     }
    573 
    574     //XXX: Following is unnecessary as a list->n = 0 should do ArrayAlloc(0) I believe.
    575     /*    if (list->n > 0) {
    576             arr = psArrayAlloc(list->n);
    577         } else {
    578             arr = psArrayAlloc(1);
    579         }
    580     */
    581     arr = psArrayAlloc(list->n);
    582     arr->n = list->n;
    583 
    584     ptr = list->head;
    585     n = list->n;
     567    PS_ASSERT_PTR_NON_NULL(list, NULL);
     568
     569    long n = list->n;
     570    psArray *arr = psArrayAlloc(n);
     571
     572    psListElem *ptr = list->head;
    586573    for (psS32 i = 0; i < n; i++) {
    587574        arr->data[i] = psMemIncrRefCounter(ptr->data);
  • trunk/psLib/src/types/psLookupTable.c

    r9715 r9730  
    77*  @author Ross Harman, MHPCC
    88*
    9 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-10-22 00:51:05 $
     9*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-10-24 22:52:56 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    3636#define MAX_STRING_LENGTH   256
    3737#define ARRAY_STRIDE        16
    38 
     38#define INITIAL_NUM         10          // Initial number of elements
    3939/******************************************************************************/
    4040/*  TYPE DEFINITIONS                                                          */
     
    449449
    450450    // Create output array and set array elements to zero
    451     outputArray = psArrayAlloc(10);
    452     outputArray->n = 0;
     451    outputArray = psArrayAllocEmpty(INITIAL_NUM);
    453452
    454453    // Parse the format string to determine how many vectors
     
    629628    // Check if array is sorted on the index column
    630629    psVector* sortedIndex = psVectorAlloc(numRows,PS_TYPE_U32);
    631     sortedIndex->n = numRows;
    632630    sortedIndex = psVectorSortIndex(sortedIndex,indexColumnVector);
    633631    for(psS32 i = 0; i < numRows; i++ ) {
     
    645643            psS32 type = ((psVector*)(vectors->data[j]))->type.type;
    646644            newValueArray->data[j] = psVectorAlloc(numRows,type);
    647             ((psVector*)(newValueArray->data[j]))->n = numRows;
    648             newValueArray->n++;
    649645        }
    650646
  • trunk/psLib/src/types/psMetadataConfig.c

    r9720 r9730  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-10-24 01:15:47 $
     12*  @version $Revision: 1.96 $ $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
     
    4747/** Maximum size of a string */
    4848#define MAX_STRING_LENGTH 1024
     49#define INITIAL_LENGTH 10               // Initial length for arrays
    4950
    5051/******************************************************************************/
     
    7374static psMetadata* setMetadataItem(psMetadata* template, char* linePtr)
    7475;
    75 static void parseLevelInfoFree(p_psParseLevelInfo* info);
    76 static psBool parseLine(psS32* level,   psArray* levelArray, char*  linePtr, psS32 lineCount, psBool overwrite);
    77 static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray, char* linePtr, psS32 lineCount, psMetadataFlags flags);
     76static psBool parseLine(psS32* level,   psArray* levelArray, char*  linePtr,
     77                        psS32 lineCount, psBool overwrite);
     78static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray,
     79                                char* linePtr, psS32 lineCount, psMetadataFlags flags);
    7880static psString formatMetadataItem(psMetadataItem *item);
    7981static psArray *p_psMetadataKeyArray(psMetadata *md);
     82
     83
     84// A metadata data structure used in parsing arrays.
     85// Contains array information and the metadata storage location.
     86typedef struct
     87{
     88    psArray*    nonUniqueKeyArray;     ///< non-unique key names
     89    psArray*    typeArray;             ///< array of user defined types
     90    psArray*    templateArray;         ///< array of user type templates
     91    psMetadata* metadata;              ///< metadata container
     92    char*       name;                  ///< name of key
     93}
     94p_psParseLevelInfo;
     95
    8096static void parseLevelInfoFree(p_psParseLevelInfo* info)
    8197{
     
    85101    psFree(info->name);
    86102    psFree(info->metadata);
     103}
     104
     105static p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)
     106{
     107    // Allocate memory for parse level info
     108    p_psParseLevelInfo *info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));
     109    psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);
     110
     111    info->nonUniqueKeyArray = psArrayAllocEmpty(INITIAL_LENGTH);
     112    info->typeArray = psArrayAllocEmpty(INITIAL_LENGTH);
     113    info->templateArray = psArrayAllocEmpty(INITIAL_LENGTH);
     114    info->metadata = NULL;
     115    info->name = NULL;
     116
     117    return info;
    87118}
    88119
     
    350381        inString = saveValue;
    351382        end = NULL;
    352         vec = psVectorAlloc(numValues, elemType);
     383        vec = psVectorAllocEmpty(numValues, elemType);
    353384
    354385        while(*inString!='\0') {
     
    406437}
    407438
     439
    408440/*****************************************************************************/
    409441/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    410442/*****************************************************************************/
    411 
    412 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)
    413 {
    414 
    415     p_psParseLevelInfo* info = NULL;
    416 
    417     // Allocate memory for parse level info
    418     info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));
    419 
    420     // If allocation successful then initialize members
    421     if(info != NULL) {
    422 
    423         info->nonUniqueKeyArray = psArrayAlloc(10);
    424 
    425         info->typeArray = psArrayAlloc(10);
    426 
    427         info->templateArray = psArrayAlloc(10);
    428 
    429         info->metadata = NULL;
    430         info->name = NULL;
    431 
    432         // Set memory deallocator
    433         psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);
    434     }
    435     return info;
    436 }
    437443
    438444bool psMetadataItemPrint(FILE * fd,
     
    12201226
    12211227    // Allocate array to store parse level information
    1222     parseLevelInfoArray = psArrayAlloc(10);
     1228    parseLevelInfoArray = psArrayAllocEmpty(INITIAL_LENGTH);
    12231229
    12241230    // Set parse level info for the top level
     
    15221528    PS_ASSERT_PTR_NON_NULL(md, NULL);
    15231529
    1524     psArray *keys = psArrayAlloc(psListLength(md->list));
     1530    psArray *keys = psArrayAllocEmpty(psListLength(md->list));
    15251531
    15261532    // since we want to preserve the order of the keys in the metadata we can't
  • trunk/psLib/src/types/psMetadataConfig.h

    r9720 r9730  
    1010 *  @author Robert DeSonia, MHPCC
    1111 *
    12  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-10-24 01:15:47 $
     12 *  @version $Revision: 1.25 $ $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
     
    2222/// @addtogroup Metadata
    2323/// @{
    24 
    25 /** A metadata data structure used in parsing arrays.
    26  *
    27  *  Contains array information and the metadata storage location.
    28 */
    29 typedef struct
    30 {
    31     psArray*    nonUniqueKeyArray;     ///< non-unique key names
    32     psArray*    typeArray;             ///< array of user defined types
    33     psArray*    templateArray;         ///< array of user type templates
    34     psMetadata* metadata;              ///< metadata container
    35     char*       name;                  ///< name of key
    36 }
    37 p_psParseLevelInfo;
    38 
    39 /** Allocates a p_psParseLevelInfo structure
    40  *
    41  *  @return p_psParseLevelInfo* :   new p_psParseLevelInfo struct
    42  */
    43 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void);
    4424
    4525/** Print metadata item to file.
  • trunk/psModules/src/astrom/pmAstrometryDistortion.c

    r8815 r9730  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-09-15 09:49:01 $
     9*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-10-24 22:55:04 $
    1111*
    1212*  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    5454
    5555    if (grads == NULL) {
    56         grads = psArrayAlloc (100);
     56        grads = psArrayAllocEmpty (100);
    5757    }
    5858
     
    7676            int Ymax = Ymin + DY;
    7777
    78             psVector *L  = psVectorAlloc (100, PS_TYPE_F32);
    79             psVector *M  = psVectorAlloc (100, PS_TYPE_F32);
    80             psVector *dP = psVectorAlloc (100, PS_TYPE_F32);
    81             psVector *dQ = psVectorAlloc (100, PS_TYPE_F32);
     78            psVector *L  = psVectorAllocEmpty (100, PS_TYPE_F32);
     79            psVector *M  = psVectorAllocEmpty (100, PS_TYPE_F32);
     80            psVector *dP = psVectorAllocEmpty (100, PS_TYPE_F32);
     81            psVector *dQ = psVectorAllocEmpty (100, PS_TYPE_F32);
    8282            int Npts = 0;
    8383
     
    121121            psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    122122            psVector *mask = psVectorAlloc (Npts, PS_TYPE_MASK);
    123             mask->n = Npts;
    124123            psVectorInit (mask, 0);
    125124
     
    175174        M->data.F32[i] = grad->FP.y;
    176175    }
    177     dPdL->n = dQdL->n = dPdM->n = dQdM->n = grads->n;
    178     L->n = M->n = grads->n;
    179176
    180177    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    181178    psVector *mask = psVectorAlloc (grads->n, PS_TYPE_MASK);
    182     mask->n = grads->n;
    183179    psVectorInit (mask, 0);
    184180
  • trunk/psModules/src/astrom/pmAstrometryObjects.c

    r9639 r9730  
    88*  @author EAM, IfA
    99*
    10 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2006-10-19 02:56:40 $
     10*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-10-24 22:55:04 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7676                            const double RADIUS) // matching radius
    7777{
    78     psArray *matches = psArrayAlloc(x1->n);
    79     matches->n = 0;
     78    psArray *matches = psArrayAllocEmpty(x1->n);
    8079
    8180    const double RADIUS_SQR = PS_SQR(RADIUS);
     
    144143    /* sort both lists by X coord; st1 first */ \
    145144    psVector *x1 = psVectorAlloc(st1->n, PS_TYPE_F64); \
    146     \
    147     x1->n = x1->nalloc; \
    148145    for (int i = 0; i < st1->n; i++) { \
    149146        x1->data.F64[i] = ((pmAstromObj *)st1->data[i])->MEMBER->x; \
     
    153150    \
    154151    psVector *y1 = psVectorAlloc(st1->n, PS_TYPE_F64); \
    155     y1->n = y1->nalloc; \
    156152    for (int i = 0; i < st1->n; i++) { \
    157153        x1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->MEMBER->x; \
     
    161157    /* now st2 */ \
    162158    psVector *x2 = psVectorAlloc(st2->n, PS_TYPE_F64); \
    163     x2->n = x2->nalloc; \
    164159    for (int i = 0; i < st2->n; i++) { \
    165160        x2->data.F64[i] = ((pmAstromObj *)st2->data[i])->MEMBER->x; \
     
    168163    \
    169164    psVector *y2 = psVectorAlloc(st2->n, PS_TYPE_F64); \
    170     y2->n = y2->nalloc; \
    171165    for (int i = 0; i < st2->n; i++) { \
    172166        x2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->MEMBER->x; \
     
    236230    psVector *y = psVectorAlloc (match->n, PS_TYPE_F32);
    237231    psVector *wt = psVectorAlloc (match->n, PS_TYPE_F32);
    238     X->n = X->nalloc;
    239     Y->n = Y->nalloc;
    240     x->n = x->nalloc;
    241     y->n = y->nalloc;
    242     wt->n = wt->nalloc;
    243232    // take the matched stars, first fit
    244233    for (int i = 0; i < match->n; i++) {
     
    259248    // constant errors
    260249    psVector *mask = psVectorAlloc (match->n, PS_TYPE_U8);
    261     mask->n = match->n;
    262250    psVectorInit (mask, 0);
    263251
     
    352340
    353341    psArray *new = psArrayAlloc (old->n);
    354     new->n = new->nalloc;
    355342    double cs = cos(angle);
    356343    double sn = sin(angle);
     
    659646    // sort the NP values and choose
    660647    psVector *listNP = psVectorAlloc (nPix*nPix, PS_TYPE_U32);
    661     listNP->n = nPix*nPix;
    662648    int n = 0;
    663649    for (int i = 0; i < nPix; i++) {
     
    780766    psVector *xHist = psVectorAlloc (nBin, PS_TYPE_F32);
    781767    psVector *yHist = psVectorAlloc (nBin, PS_TYPE_F32);
    782     xHist->n = yHist->n = nBin;
    783768    psVectorInit (xHist, 0);
    784769    psVectorInit (yHist, 0);
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r9701 r9730  
    6161    *second = psArrayAlloc(values->n);
    6262    *third = psArrayAlloc(values->n);
    63     (*first)->n = (*second)->n = (*third)->n = values->n;
    6463    int num = 0;
    6564    psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r9594 r9730  
    2929    if (!masks) {
    3030        masks = psArrayAlloc(images->n);
    31         masks->n = images->n;
    3231        hdu->masks = masks;
    3332    }
     
    5655    if (!weights) {
    5756        weights = psArrayAlloc(images->n);
    58         weights->n = images->n;
    5957        hdu->weights = weights;
    6058    }
  • trunk/psModules/src/camera/pmHDUGenerate.c

    r9603 r9730  
    294294    // Generate the HDU
    295295    hdu->images = psArrayAlloc(numReadouts);
    296     hdu->images->n = numReadouts;
    297296    for (int i = 0; i < numReadouts; i++) {
    298297        psImage *image = psImageAlloc(xSize, ySize, type);
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r9572 r9730  
    5151        }
    5252        psVector *match = psVectorAlloc(cList->n, PS_TYPE_U8); // Array indicating which values match
    53         match->n = cList->n;
    5453        psVectorInit(match, 0);
    5554        psListIterator *cIter = psListIteratorAlloc(cList, PS_LIST_HEAD, false); // compare iterator
  • trunk/psModules/src/config/pmConfig.c

    r9591 r9730  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2006-10-17 01:25:22 $
     6 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2006-10-24 22:55:05 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    883883
    884884    // we load all input files onto a psArray, to be parsed later
    885     psArray *input = psArrayAlloc (16);
    886     input->n = 0;
     885    psArray *input = psArrayAllocEmpty(16);
    887886
    888887    // load the list of filenames the supplied file
  • trunk/psModules/src/detrend/pmFlatNormalize.c

    r9614 r9730  
    3232        } else {
    3333            *expFluxesPtr = psVectorAlloc(numExps, PS_TYPE_F32);
    34             (*expFluxesPtr)->n = numExps;
    3534        }
    3635        expFluxes = psMemIncrRefCounter(*expFluxesPtr);
    3736    } else {
    3837        expFluxes = psVectorAlloc(numExps, PS_TYPE_F32);
    39         expFluxes->n = numExps;
    4038    }
    4139
     
    4745        } else {
    4846            *chipGainsPtr = psVectorAlloc(numChips, PS_TYPE_F32);
    49             (*chipGainsPtr)->n = numChips;
    5047            psVectorInit(*chipGainsPtr, 1.0);
    5148        }
     
    5350    } else {
    5451        chipGains = psVectorAlloc(numChips, PS_TYPE_F32);
    55         chipGains->n = numChips;
    5652        psVectorInit(chipGains, 1.0);
    5753    }
     
    6258    psImageInit(fluxMask, 0);
    6359    psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_U8); // Mask for bad gains
    64     gainMask->n = numChips;
    6560    psVectorInit(gainMask, 0);
    6661    psVector *expMask = psVectorAlloc(numExps, PS_TYPE_U8); // Mask for bad exposures
    67     expMask->n = numExps;
    6862    psVectorInit(expMask, 0);
    6963    for (int i = 0; i < numChips; i++) {
  • trunk/psModules/src/detrend/pmFringeStats.c

    r9615 r9730  
    133133
    134134    psArray *table = psArrayAlloc(numRows); // The table
    135     table->n = numRows;
    136135    // Translate the vectors into the required format for psFitsWriteTable()
    137136    for (long i = 0; i < numRows; i++) {
     
    205204    psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
    206205    psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
    207     x->n = y->n = mask->n = numRows;
    208206    regions->x = x;
    209207    regions->y = y;
     
    253251    stats->f = psVectorAlloc(numRegions, PS_TYPE_F32);
    254252    stats->df = psVectorAlloc(numRegions, PS_TYPE_F32);
    255     stats->f->n = stats->df->n = numRegions;
    256253
    257254    return stats;
     
    365362    // Vectors: f, df
    366363    psArray *table = psArrayAlloc(numRows); // The table
    367     table->n = numRows;
    368364    // Translate the vectors into the required format for psFitsWriteTable()
    369365    for (long i = 0; i < numRows; i++) {
     
    527523    scale->coeff = psVectorAlloc(nFringeFrames + 1, PS_TYPE_F32);
    528524    scale->coeffErr = psVectorAlloc(nFringeFrames + 1, PS_TYPE_F32);
    529     scale->coeff->n = nFringeFrames + 1;
    530     scale->coeff->n = nFringeFrames + 1;
    531525
    532526    return scale;
     
    551545    psImage *A = psImageAlloc(numCoeffs, numCoeffs, PS_TYPE_F64); // The least-squares matrix
    552546    psVector *B = psVectorAlloc(numCoeffs, PS_TYPE_F64); // The least-squares vector
    553     B->n = numCoeffs;
    554547
    555548    // Generate the least-squares matrix and vector
     
    718711    if (!regions->mask) {
    719712        regions->mask = psVectorAlloc(numRegions, PS_TYPE_U8);
    720         regions->mask->n = numRegions;
    721713        psVectorInit(regions->mask, 0);
    722714    }
     
    725717    unsigned int numClipped = 0;        // Total number clipped
    726718    psVector *diff = psVectorAlloc(numRegions, PS_TYPE_F32); // The differences between obs. and pred.
    727     diff->n = numRegions;
    728719
    729720    pmFringeScale *scale = pmFringeScaleAlloc(fringes->n); // The fringe scales
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r9618 r9730  
    104104    psVector *tmpX = psVectorAlloc(2, PS_TYPE_F32);
    105105    psVector *tmpY = psVectorAlloc(2, PS_TYPE_F32);
    106     tmpX->n = tmpY->n = 2;
    107106
    108107    long index;
     
    210209    psVector *x = psVectorAlloc(exptime->n, PS_TYPE_F32);
    211210    psVector *y = psVectorAlloc(exptime->n, PS_TYPE_F32);
    212     x->n = y->n = exptime->n;
    213211
    214212    for (long i = 0; i < exptime->n; i++) {
     
    301299    params->data.F32[1] = guess->offset;
    302300    params->data.F32[2] = guess->offref;
    303     params->n = 3;
    304301
    305302    // XXX for the moment, don't set any constraints
     
    317314    // construct the coordinate and value entries (y is counts)
    318315    psArray *x = psArrayAlloc(exptime->n); // Coordinates
    319     x->n = exptime->n;
    320316
    321317    for (long i = 0; i < exptime->n; i++) {
    322318        psVector *coord = psVectorAlloc(1, PS_TYPE_F32);
    323         coord->n = 1;
    324319        coord->data.F32[0] = exptime->data.F32[i];
    325320        x->data[i] = coord;
     
    371366    psRegion refRegion;                 // Reference region
    372367    psVector *refs = psVectorAlloc(num, PS_TYPE_F32); // Reference measurements
    373     refs->n = num;
    374368    psVectorInit(refs, 0);
    375369    psArray *regions = psArrayAlloc(MEASURE_SAMPLES); // Array of sample regions, made on each image
    376     regions->n = MEASURE_SAMPLES;
    377370    psImage *samplesMean = psImageAlloc(num, MEASURE_SAMPLES, PS_TYPE_F32); // Measurements for each file
    378371    psImage *samplesStdev = psImageAlloc(num, MEASURE_SAMPLES, PS_TYPE_F32); // Errors for each file
     
    505498    psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
    506499    psVector *mask = psVectorAlloc(num, PS_TYPE_U8); // Mask for each image
    507     mask->n = num;
    508500    psVectorInit(mask, 0);
    509501    psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n");
  • trunk/psModules/src/detrend/pmSubtractBias.c

    r9619 r9730  
    129129    psVector *ordinate = psVectorAlloc(pixels->n, PS_TYPE_F32); // Ordinate
    130130    psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_U8); // Mask for fitting
    131     reduced->n = ordinate->n = mask->n = pixels->n;
    132131
    133132    for (int i = 0; i < pixels->n; i++) {
     
    268267                // The read direction is rows
    269268                psArray *pixels = psArrayAlloc(image->numRows); // Array of vectors containing pixels
    270                 pixels->n = image->numRows;
    271269                for (int i = 0; i < pixels->n; i++) {
    272270                    psVector *values = psVectorAlloc(0, PS_TYPE_F32);
     
    312310                // The read direction is columns
    313311                psArray *pixels = psArrayAlloc(image->numCols); // Array of vectors containing pixels
    314                 pixels->n = image->numCols;
    315312                for (int i = 0; i < pixels->n; i++) {
    316313                    psVector *values = psVectorAlloc(0, PS_TYPE_F32);
  • trunk/psModules/src/detrend/pmSubtractSky.c

    r9541 r9730  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-10-13 22:11:02 $
     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
     
    345345    psImage *Aout = psImageAlloc(localPolyTerms, localPolyTerms, PS_TYPE_F64);
    346346    psVector *B = psVectorAlloc(localPolyTerms, PS_TYPE_F64);
    347     B->n = B->nalloc;
    348347    psVector *outPerm = NULL;
    349348
     
    412411    PS_ASSERT_IMAGE_NON_EMPTY(Aout, NULL);
    413412    psVector *C = psVectorAlloc(localPolyTerms, PS_TYPE_F64);
    414     C->n = C->nalloc;
    415413    psMatrixLUSolve(C, Aout, B, outPerm);
    416414
  • trunk/psModules/src/imcombine/pmImageCombine.c

    r8815 r9730  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-09-15 09:49:01 $
     10 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-10-24 22:55:05 $
    1212 *
    1313 *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
     
    122122    if (*questionablePixels == NULL) {
    123123        *questionablePixels = psArrayAlloc(numImages);
    124         (*questionablePixels)->n = numImages;
    125124    } else if ((*questionablePixels)->n != numImages) {
    126125        *questionablePixels = psArrayRealloc(*questionablePixels, numImages);
     
    137136    psVector *qpPtr = psVectorAlloc(numImages, PS_TYPE_S32);
    138137    psVectorInit(qpPtr, 0);
    139     qpPtr->n = numImages;
    140138    //
    141139    // Allocate the necessary psVectors for the call to psVectorStats().
     
    144142    //
    145143    psVector *pixelData = psVectorAlloc(numImages, PS_TYPE_F32);
    146     pixelData->n = pixelData->nalloc;
    147144    psVector *pixelMask = NULL;
    148145    if (masks != NULL) {
    149146        pixelMask = psVectorAlloc(numImages, PS_TYPE_U8);
    150147        psVectorInit(pixelMask, 0);
    151         pixelMask->n = numImages;
    152148    }
    153149
     
    156152        pixelErrors = psVectorAlloc(numImages, PS_TYPE_F32);
    157153        psVectorInit(pixelErrors, 1.0);
    158         pixelErrors->n = numImages;
    159154    }
    160155
     
    320315    psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels
    321316    psVector *mask = psVectorAlloc(8, PS_TYPE_U8); // Corresponding mask
    322     pixels->n = 8;
    323     mask->n = 8;
    324317
    325318    // Get limits
     
    538531    //
    539532    psArray *rejects = psArrayAlloc(numImages);
    540     rejects->n = numImages;
    541533    for (psS32 im = 0 ; im < numImages ; im++) {
    542534        rejects->data[im] = (psPtr *) psPixelsAlloc(PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH);
     
    550542    psVector *rPtr = psVectorAlloc(numImages, PS_TYPE_S32);
    551543    psVectorInit(rPtr, 0);
    552     rPtr->n = numImages;
    553544
    554545    psS32 numCols = ((psImage *) images->data[0])->numCols;
  • trunk/psModules/src/imcombine/pmImageSubtract.c

    r8815 r9730  
    77 *  @author GLG, MHPCC
    88 *
    9  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-09-15 09:49:01 $
     9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-10-24 22:55:05 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    122122    tmp->u = psVectorAlloc(nBF, PS_TYPE_F32);
    123123    tmp->v = psVectorAlloc(nBF, PS_TYPE_F32);
    124     tmp->u->n = tmp->u->nalloc;
    125     tmp->v->n = tmp->v->nalloc;
    126124    tmp->sigma = NULL;
    127125    tmp->xOrder = psVectorAlloc(nBF, PS_TYPE_F32);
    128     tmp->xOrder->n = tmp->xOrder->nalloc;
    129126    tmp->yOrder = psVectorAlloc(nBF, PS_TYPE_F32);
    130     tmp->yOrder->n = tmp->yOrder->nalloc;
    131127    tmp->subIndex = 0;
    132128    tmp->preCalc = NULL;
     
    223219    tmp->u = psVectorAlloc(nBF, PS_TYPE_F32);
    224220    tmp->v = psVectorAlloc(nBF, PS_TYPE_F32);
    225     tmp->u->n = tmp->u->nalloc;
    226     tmp->v->n = tmp->v->nalloc;
    227221    tmp->sigma = psVectorAlloc(nBF, PS_TYPE_F32);
    228222    tmp->xOrder = psVectorAlloc(nBF, PS_TYPE_F32);
     
    232226    tmp->spatialOrder = spatialOrder;
    233227    tmp->preCalc = psArrayAlloc(nBF);
    234     tmp->u->n = tmp->u->nalloc;
    235     tmp->v->n = tmp->v->nalloc;
    236     tmp->sigma->n = tmp->sigma->nalloc;
    237     tmp->xOrder->n = tmp->xOrder->nalloc;
    238     tmp->yOrder->n = tmp->yOrder->nalloc;
    239     tmp->preCalc->n = tmp->preCalc->nalloc;
    240228
    241229    //
     
    367355    } else {
    368356        stamps = (psArray *) psArrayAlloc(xNum * yNum);
    369         stamps->n = stamps->nalloc;
    370357        for (psS32 s = 0 ; s < (xNum * yNum) ; s++) {
    371358            stamps->data[s] = (psPtr *) p_pmStampAlloc(PM_STAMP_REJECTED);
     
    826813            if (stampVector == NULL) {
    827814                stampVector = psVectorAlloc(numSolveParams, PS_TYPE_F64);
    828                 stampVector->n = stampVector->nalloc;
    829815                stamp->vector = stampVector;
    830816            } else {
     
    10451031    } else {
    10461032        solution = psVectorAlloc(size, PS_TYPE_F64);
    1047         solution->n = solution->nalloc;
    10481033    }
    10491034
     
    10571042    psImage *sumMatrix = psImageAlloc(size, size, PS_TYPE_F64);
    10581043    psVector *sumVector = psVectorAlloc(size, PS_TYPE_F64);
    1059     sumVector->n = sumVector->nalloc;
    10601044    psVectorInit(sumVector, 0.0);
    10611045    psImageInit(sumMatrix, 0.0);
     
    11501134    } else {
    11511135        deviations = psVectorAlloc(stamps->n, PS_TYPE_F32);
    1152         deviations->n = deviations->nalloc;
    11531136        // XXX: Probably not necessary.
    11541137        psVectorInit(deviations, 0.0);
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r9611 r9730  
    201201
    202202    psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels
    203     pixels->n = inputs->n;
    204203    psF32 *pixelsData = pixels->data.F32; // Dereference pixels
    205204
    206205    psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack
    207     mask->n = inputs->n;
    208206    psU8 *maskData = mask->data.U8;     // Dereference mask
    209207
     
    212210    if (haveWeights) {
    213211        weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights
    214         weights->n = inputs->n;
    215212        weightsData = weights->data.F32;
    216213    }
  • 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.