IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2004, 1:29:39 PM (22 years ago)
Author:
harman
Message:

Changed psVector to be consistent with psImage

Location:
trunk/psLib/src/collections
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psSort.c

    r670 r831  
    1414 *  @author Ross Harman, MHPCC
    1515 *   
    16  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2004-05-13 22:47:52 $
     16 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2004-06-02 23:29:14 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    129129    inN = inVector->n;
    130130    outN = outVector->n;
    131     inVec = inVector->vec.f;
    132     outVec = outVector->vec.f;
     131    inVec = inVector->data.F32;
     132    outVec = outVector->data.F32;
    133133    elSize = sizeof(float);
    134134
     
    188188    inN = inVector->n;
    189189    outN = outVector->n;
    190     inVec = inVector->vec.f;
    191     outVec = outVector->vec.i32;
     190    inVec = inVector->data.F32;
     191    outVec = outVector->data.S32;
    192192
    193193    if(inN != outN) {
     
    197197    }
    198198
    199     tmpFloatVector = psVectorAlloc(PS_TYPE_FLOAT, inN);
     199    tmpFloatVector = psVectorAlloc(inN, PS_TYPE_F32);
    200200    tmpFloatVector->n = inN;
    201201    tmpFloatVector = psSort(tmpFloatVector, inVector);
    202202
    203203    for(i=0; i<inN; i++) {
    204         tempVal = tmpFloatVector->vec.f[i];
     204        tempVal = tmpFloatVector->data.F32[i];
    205205        for(j=0; j<inN; j++) {
    206206            diff = fabsf(tempVal - inVec[j]);
  • trunk/psLib/src/collections/psVector.c

    r811 r831  
    1919 *  @author Ross Harman, MHPCC
    2020 *   
    21  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2004-05-29 01:08:46 $
     21 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     22 *  @date $Date: 2004-06-02 23:29:14 $
    2323 *
    2424 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6464/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    6565/*****************************************************************************/
    66 psVector* psVectorAlloc(psElemType elemType, unsigned int nalloc)
     66psVector* psVectorAlloc(unsigned int nalloc, psElemType elemType)
    6767{
    6868    psVector *psVec = NULL;
     
    8686
    8787    // Create vector data array
    88     psVec->vec.v = psAlloc(nalloc*elementSize);
     88    psVec->data.V = psAlloc(nalloc*elementSize);
    8989
    9090    return psVec;
    9191}
    9292
    93 psVector *psVectorRealloc(psVector *restrict in, unsigned int nalloc)
     93psVector *psVectorRealloc(unsigned int nalloc, psVector *restrict in)
    9494{
    9595    int elementSize = 0;
     
    110110            if (elemType == PS_TYPE_PTR) {
    111111                for (int i = nalloc; i < in->n; i++) {   // For reduction in vector size
    112                     psMemDecrRefCounter(in->vec.vp[i]);
     112                    psMemDecrRefCounter(in->data.PTR[i]);
    113113                }
    114114            }
     
    117117
    118118        // Realloc after decrementation to avoid accessing freed array elements
    119         in->vec.v = psRealloc(in->vec.v,nalloc*elementSize);
     119        in->data.V = psRealloc(in->data.V,nalloc*elementSize);
    120120        in->nalloc = nalloc;
    121121    }
     
    129129
    130130    if (in == NULL) {
    131         return psVectorAlloc(type,nalloc);
     131        return psVectorAlloc(nalloc, type);
    132132    }
    133133
     
    150150    if (elemType == PS_TYPE_PTR) {
    151151        for (int i = 0; i < in->n; i++) {   // For reduction in vector size
    152             psMemDecrRefCounter(in->vec.vp[i]);
    153             in->vec.vp[i] = NULL;
     152            psMemDecrRefCounter(in->data.PTR[i]);
     153            in->data.PTR[i] = NULL;
    154154        }
    155155    }
    156156
    157     in->vec.v = psRealloc(in->vec.v,nalloc*PSELEMTYPE_SIZEOF(elemType));
     157    in->data.V = psRealloc(in->data.V,nalloc*PSELEMTYPE_SIZEOF(elemType));
    158158
    159159    in->n = 0;
     
    170170    }
    171171
    172     psFree(psVec->vec.v);
     172    psFree(psVec->data.V);
    173173    psFree(psVec);
    174174}
     
    188188    for(int i = 0; i < psVec->nalloc; i++) {
    189189        if(elemFree == NULL) {
    190             psMemDecrRefCounter(psVec->vec.vp[i]);
     190            psMemDecrRefCounter(psVec->data.PTR[i]);
    191191        } else {
    192             elemFree(psMemDecrRefCounter(psVec->vec.vp[i]));
     192            elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
    193193        }
    194         psVec->vec.vp[i] = NULL;
     194        psVec->data.PTR[i] = NULL;
    195195    }
    196196}
  • trunk/psLib/src/collections/psVector.h

    r811 r831  
    11/** @file  psVector.h
    22 *
    3  *  @brief Contains support for basic vector types
     3 *  @brief Contains basic vector definitions and operations
    44 *
    5  *  This file defines types and functions for one dimensional vectors which include:
    6  *      char
    7  *      short
    8  *      int
    9  *      long
    10  *      unsigned char
    11  *      unsigned short
    12  *      unsigned int
    13  *      unsigned long
    14  *      float
    15  *      double
    16  *      complex float
    17  *      void **
     5 *  This file defines the basic type for a vector struct and functions useful
     6 *  in manupulating vectors.
    187 *
     8 *  @author Robert DeSonia, MHPCC
    199 *  @author Ross Harman, MHPCC
    2010 *
    21  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2004-05-29 01:08:46 $
     11 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-02 23:29:14 $
    2313 *
    2414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4232
    4333    union {
    44         int8_t *i8;                     ///< Pointers to char integer data.
    45         int16_t *i16;                   ///< Pointers to short integer data.
    46         int32_t *i32;                   ///< Pointers to integer data.
    47         int64_t *i64;                   ///< Pointers to long integer data.
    48         uint8_t *ui8;                   ///< Pointers to unsigned char integer data.
    49         uint16_t*ui16;                  ///< Pointers to unsigned short integer data.
    50         uint32_t *ui32;                 ///< Pointers to unsigned integer data.
    51         uint64_t *ui64;                 ///< Pointers to unsigned long integer data.
    52         float *f;                       ///< Pointers to floating point data.
    53         double *d;                      ///< Pointers to double precision data.
    54         complex float *cf;              ///< Pointers to complex floating point data.
    55         void *v;                        ///< Pointers to generic void data
    56         void **vp;                      ///< Void pointer vector.
    57     }vec;                               ///< Union for data types.
     34        psU8    *U8;                    ///< Unsigned 8-bit integer data.
     35        psU16   *U16;                   ///< Unsigned 16-bit integer data.
     36        psU32   *U32;                   ///< Unsigned 32-bit integer data.
     37        psU64   *U64;                   ///< Unsigned 64-bit integer data.
     38        psS8    *S8;                    ///< Signed 8-bit integer data.
     39        psS16   *S16;                   ///< Signed 16-bit integer data.
     40        psS32   *S32;                   ///< Signed 32-bit integer data.
     41        psS64   *S64;                   ///< Signed 64-bit integer data.
     42        psF32   *F32;                   ///< Single-precision float data.
     43        psF64   *F64;                   ///< Double-precision float data.
     44        psC32   *C32;                   ///< Single-precision complex data.
     45        psC64   *C64;                   ///< Double-precision complex data.
     46        psPTR   *PTR;                   ///< Void pointers
     47        psPTR    V;                     ///< Pointer to data
     48    } data;                             ///< Union for data types.
    5849}
    5950psVector;
     
    7162 */
    7263psVector *psVectorAlloc(
    73     psElemType dataType,                ///< Type of data to be held by vector.
    74     unsigned int nalloc                 ///< Total number of elements to make available.
     64    unsigned int nalloc,                ///< Total number of elements to make available.
     65    psElemType dataType                 ///< Type of data to be held by vector.
    7566);
    7667
     
    8475 */
    8576psVector *psVectorRealloc(
    86     psVector *restrict psVec,           ///< Vector to reallocate.
    87     unsigned int nalloc                 ///< Total number of elements to make available.
     77    unsigned int nalloc,                ///< Total number of elements to make available.
     78    psVector *restrict psVec            ///< Vector to reallocate.
    8879);
    8980
Note: See TracChangeset for help on using the changeset viewer.