IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11698


Ignore:
Timestamp:
Feb 7, 2007, 4:59:36 PM (19 years ago)
Author:
jhoblitt
Message:

change psVectorRecycle(), psVectorCopy, & psVectorCreate() into wrappers so file/lineo/func can be recorded in the memBlock
whitespace cleanup

Location:
trunk/psLib/src/mathtypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psVector.c

    r11697 r11698  
    1010*  @author Joshua Hoblitt, University of Hawaii
    1111*
    12 *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2007-02-08 02:42:46 $
     12*  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2007-02-08 02:59:36 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    153153}
    154154
    155 psVector* psVectorRecycle(psVector* vector,
    156                           long nalloc,
    157                           psElemType type)
     155psVector* p_psVectorRecycle(const char *file,
     156                            unsigned int lineno,
     157                            const char *func,
     158                            psVector* vector,
     159                            long nalloc,
     160                            psElemType type)
    158161{
    159162    psS32 byteSize;
    160163
    161164    if (vector == NULL) {
    162         return psVectorAlloc(nalloc, type);
     165        return p_psVectorAlloc(file, lineno, func, nalloc, type);
    163166    }
    164167
     
    224227}
    225228
    226 psVector* psVectorCopy(psVector* output,
     229psVector* p_psVectorCopy(const char *file,
     230                       unsigned int lineno,
     231                       const char *func,
     232                       psVector* output,
    227233                       const psVector* input,
    228234                       psElemType type)
     
    237243    psS32 nElements = input->n;
    238244
    239     output = psVectorRecycle(output, nElements, type);
     245    output = p_psVectorRecycle(file, lineno, func, output, nElements, type);
    240246    if (nElements == 0) {
    241247        //        psWarning("Warning: psVector was copied with 0 elements!\n");
     
    854860
    855861#define FUNC_MACRO_VECTOR_CREATE(TYPE) \
    856 static psVector *vectorCreate##TYPE(psVector *input, double lower, double upper, double delta) \
     862static psVector *vectorCreate##TYPE(const char *file, unsigned int lineno, const char *func, psVector *input, double lower, double upper, double delta) \
    857863{ \
    858864    \
    859865    int nBin = (upper - lower) / delta; \
    860     psVector *vec = psVectorRecycle(input, nBin, PS_TYPE_##TYPE); \
     866    psVector *vec = p_psVectorRecycle(file, lineno, func, input, nBin, PS_TYPE_##TYPE); \
    861867    vec->n = nBin; \
    862868    for (int i = 0; i < nBin; i++) \
     
    878884FUNC_MACRO_VECTOR_CREATE(F64)
    879885
    880 psVector *psVectorCreate (psVector *input,
    881                           double lower,
    882                           double upper,
    883                           double delta,
    884                           psElemType type)
     886psVector *p_psVectorCreate(const char *file,
     887                           unsigned int lineno,
     888                           const char *func,
     889                           psVector *input,
     890                           double lower,
     891                           double upper,
     892                           double delta,
     893                           psElemType type)
    885894{
    886895    psVector *out = NULL;
    887896    switch (type) {
    888897    case PS_TYPE_S8:
    889         out = vectorCreateS8(input, lower,  upper, delta);
     898        out = vectorCreateS8(file, lineno, func, input, lower,  upper, delta);
    890899        break;
    891900    case PS_TYPE_S16:
    892         out = vectorCreateS16(input, lower, upper, delta);
     901        out = vectorCreateS16(file, lineno, func, input, lower, upper, delta);
    893902        break;
    894903    case PS_TYPE_S32:
    895         out = vectorCreateS32(input, lower, upper, delta);
     904        out = vectorCreateS32(file, lineno, func, input, lower, upper, delta);
    896905        break;
    897906    case PS_TYPE_S64:
    898         out = vectorCreateS64(input, lower, upper, delta);
     907        out = vectorCreateS64(file, lineno, func, input, lower, upper, delta);
    899908        break;
    900909    case PS_TYPE_U8:
    901         out = vectorCreateU8(input, lower, upper, delta);
     910        out = vectorCreateU8(file, lineno, func, input, lower, upper, delta);
    902911        break;
    903912    case PS_TYPE_U16:
    904         out = vectorCreateU16(input, lower, upper, delta);
     913        out = vectorCreateU16(file, lineno, func, input, lower, upper, delta);
    905914        break;
    906915    case PS_TYPE_U32:
    907         out = vectorCreateU32(input, lower, upper, delta);
     916        out = vectorCreateU32(file, lineno, func, input, lower, upper, delta);
    908917        break;
    909918    case PS_TYPE_U64:
    910         out = vectorCreateU64(input, lower, upper, delta);
     919        out = vectorCreateU64(file, lineno, func, input, lower, upper, delta);
    911920        break;
    912921    case PS_TYPE_F32:
    913         out = vectorCreateF32(input, lower, upper, delta);
     922        out = vectorCreateF32(file, lineno, func, input, lower, upper, delta);
    914923        break;
    915924    case PS_TYPE_F64:
    916         out = vectorCreateF64(input, lower, upper, delta);
     925        out = vectorCreateF64(file, lineno, func, input, lower, upper, delta);
    917926        break;
    918927    default:
  • trunk/psLib/src/mathtypes/psVector.h

    r11697 r11698  
    1010 * @author Joshua Hoblitt, University of Hawaii
    1111 *
    12  * @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
    13  * @date $Date: 2007-02-08 02:42:46 $
     12 * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
     13 * @date $Date: 2007-02-08 02:59:36 $
    1414 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1515 */
     
    5454#define P_PSVECTOR_SET_NALLOC(vec,n) *(long*)&(vec->nalloc) = n
    5555
    56         /*****************************************************************************/
    57 
    58         /* FUNCTION PROTOTYPES                                                       */
    59 
    60         /*****************************************************************************/
    61 
    62         /** Checks the type of a particular pointer.
    63          *
    64          *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
    65          *
    66          *  @return bool:       True if the pointer matches a psVector structure, false otherwise.
    67          */
    68         bool psMemCheckVector(
    69             psPtr ptr                          ///< the pointer whose type to check
    70         )
    71         ;
     56/*****************************************************************************/
     57
     58/* FUNCTION PROTOTYPES                                                       */
     59
     60/*****************************************************************************/
     61
     62/** Checks the type of a particular pointer.
     63 *
     64 *  Uses the appropriate deallocation function in psMemBlock to check the ptr
     65 *  datatype.
     66 *
     67 *  @return bool:       True if the pointer matches a psVector structure, false
     68 *  otherwise.
     69 */
     70bool psMemCheckVector(
     71    psPtr ptr                          ///< the pointer whose type to check
     72)
     73;
    7274
    7375/** Allocate a vector, with length set to number allocated
     
    169171 *
    170172 */
     173#ifdef DOXYGEN
    171174psVector* psVectorRecycle(
    172175    psVector* vector,
     
    174177    ///< taken to preserve the values.
    175178
    176     long nalloc,                       ///< Total number of elements to make available.
    177     psElemType type                    ///< the datatype of the returned vector
    178 );
     179    long nalloc,                        ///< Total number of elements to make available.
     180    psElemType type                     ///< the datatype of the returned vector
     181);
     182#else // ifdef DOXYGEN
     183psVector* p_psVectorRecycle(
     184    const char *file,                   ///< File of caller
     185    unsigned int lineno,                ///< Line number of caller
     186    const char *func,                   ///< Function name of caller
     187    psVector* vector,
     188    ///< Vector to recycle.  If NULL, a new vector is created.  No effort
     189    ///< taken to preserve the values.
     190
     191    long nalloc,                        ///< Total number of elements to make available.
     192    psElemType type                     ///< the datatype of the returned vector
     193);
     194#define psVectorRecycle(vector, nalloc, type) \
     195      p_psVectorRecycle(__FILE__, __LINE__, __func__, vector, nalloc, type)
     196#endif // ifdef DOXYGEN
    179197
    180198
     
    187205 *
    188206 */
     207#ifdef DOXYGEN
    189208psVector* psVectorCopy(
    190209    psVector* output,                  ///< if non-NULL, a psVector to recycle
     
    192211    psElemType type                    ///< the data type of the resulting psVector
    193212);
     213#else // ifdef DOXYGEN
     214psVector* p_psVectorCopy(
     215    const char *file,                   ///< File of caller
     216    unsigned int lineno,                ///< Line number of caller
     217    const char *func,                   ///< Function name of caller
     218    psVector* output,                  ///< if non-NULL, a psVector to recycle
     219    const psVector* input,             ///< the vector to copy.
     220    psElemType type                    ///< the data type of the resulting psVector
     221);
     222#define psVectorCopy(output, input, type) \
     223      p_psVectorCopy(__FILE__, __LINE__, __func__, output, input, type)
     224#endif // ifdef DOXYGEN
    194225
    195226
     
    244275 *  @return bool          TRUE is successful, otherwise FALSE.
    245276 */
    246 bool p_psVectorPrint (
     277bool p_psVectorPrint(
    247278    int fd,                            ///< output file descriptor
    248279    const psVector *a,                       ///< vector to print
     
    272303 *  @return psVector*:       the newly created psVector
    273304 */
    274 psVector *psVectorCreate (
     305#ifdef DOXYGEN
     306psVector *psVectorCreate(
    275307    psVector *input,                   ///< Input vector
    276308    double lower,                      ///< lower bound
     
    279311    psElemType type                    ///< type of vector to create
    280312);
     313#else // ifdef DOXYGEN
     314psVector *p_psVectorCreate(
     315    const char *file,                   ///< File of caller
     316    unsigned int lineno,                ///< Line number of caller
     317    const char *func,                   ///< Function name of caller
     318    psVector *input,                   ///< Input vector
     319    double lower,                      ///< lower bound
     320    double upper,                      ///< upper bound
     321    double delta,                      ///< size of increment
     322    psElemType type                    ///< type of vector to create
     323);
     324#define psVectorCreate(input, lower, upper, delta, type) \
     325      p_psVectorCreate(__FILE__, __LINE__, __func__, input, lower, upper, delta, type)
     326#endif // ifdef DOXYGEN
    281327
    282328
Note: See TracChangeset for help on using the changeset viewer.