Changeset 672
- Timestamp:
- May 13, 2004, 1:36:27 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 added
- 4 edited
-
collections/psVector.c (modified) (4 diffs)
-
collections/psVector.h (modified) (4 diffs)
-
mathtypes/psVector.c (modified) (4 diffs)
-
mathtypes/psVector.h (modified) (4 diffs)
-
sys/psType.h (added)
-
sysUtils/psType.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psVector.c
r670 r672 19 19 * @author Ross Harman, MHPCC 20 20 * 21 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $22 * @date $Date: 2004-05-13 2 2:47:52$21 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2004-05-13 23:36:27 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 } 76 76 77 if (elemType == PS_TYPE_PTR) { 78 elementSize = sizeof(void*); 79 } else { 80 elementSize = PSELEMTYPE_SIZEOF(elemType); 81 } 77 elementSize = PSELEMTYPE_SIZEOF(elemType); 82 78 83 79 // Create vector struct … … 102 98 // Invalid nalloc 103 99 if(nalloc < 1) { 104 psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);100 psError(__func__, "Invalid value for nalloc (%d)\n", nalloc); 105 101 return NULL; 106 102 } 107 103 108 if (elemType == PS_TYPE_PTR) { 109 elementSize = sizeof(void*); 110 } else { 111 elementSize = PSELEMTYPE_SIZEOF(elemType); 112 } 104 elementSize = PSELEMTYPE_SIZEOF(elemType); 113 105 114 106 … … 137 129 } 138 130 139 if (psVec->type.type == PS_TYPE_PTR) { 140 psLogMsg(__func__,PS_LOG_WARN,"psVectorFree was called with a void* vector. " 141 "Referenced of pointers was not freed."); 142 psVoidPtrVectorFree(psVec,NULL); 143 } else { 144 psFree(psVec->vec.v); 145 psFree(psVec); 146 } 131 psFree(psVec->vec.v); 132 psFree(psVec); 147 133 } 148 134 -
trunk/psLib/src/collections/psVector.h
r670 r672 3 3 * @brief Contains support for basic vector types 4 4 * 5 * This file defines types and functions for one dimensional vectors which include: 5 * This file defines types and functions for one dimensional vectors which include: 6 6 * char 7 7 * short … … 18 18 * 19 19 * @author Ross Harman, MHPCC 20 * 21 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $22 * @date $Date: 2004-05-13 2 2:47:52$20 * 21 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2004-05-13 23:36:27 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #define PS_VECTOR_H 29 29 30 #include <complex.h> 31 #include <stdint.h> 32 33 /******************************************************************************/ 34 /* DEFINE STATEMENTS */ 35 /******************************************************************************/ 36 37 // None 38 39 /******************************************************************************/ 40 /* TYPE DEFINITIONS */ 41 /******************************************************************************/ 42 43 /** Basic data types used by the containers. 44 * 45 * The basic types of the primitives used by psLib are defined within this enum. This enum is in turn used by 46 * the psType struct. 47 * 48 */ 49 typedef enum { 50 PS_TYPE_INT8 = 0x11, ///< Character. 51 PS_TYPE_INT16 = 0x12, ///< Short integer. 52 PS_TYPE_INT32 = 0x14, ///< Integer. 53 PS_TYPE_INT64 = 0x18, ///< Long integer. 54 PS_TYPE_UINT8 = 0x31, ///< Unsigned character. 55 PS_TYPE_UINT16 = 0x32, ///< Unsigned short integer. 56 PS_TYPE_UINT32 = 0x34, ///< Unsigned integer. 57 PS_TYPE_UINT64 = 0x38, ///< Unsigned long integer. 58 PS_TYPE_FLOAT = 0x44, ///< Single-precision Floating point. 59 PS_TYPE_DOUBLE = 0x48, ///< Double-precision floating point. 60 PS_TYPE_COMPLEX_FLOAT = 0x84, ///< Complex numbers consisting of single-precision floating point. 61 PS_TYPE_COMPLEX_DOUBLE = 0x88, ///< Complex numbers consisting of double-precision floating point. 62 PS_TYPE_PTR = 0x00, ///< Something else that's not supported for arithmetic.} 63 } psElemType; 64 65 #define IS_PSELEMTYPE_INT(x) (x & 0x10 == 0x10) 66 #define IS_PSELEMTYPE_UNSIGNED(x) (x & 0x20 == 0x20) 67 #define IS_PSELEMTYPE_REAL(x) (x & 0x40 == 0x40) 68 #define IS_PSELEMTYPE_COMPLEX(x) (x & 0x80 == 0x80) 69 #define PSELEMTYPE_SIZEOF(x) (x & 0x0F) 70 71 /** Dimensions of a data type. 72 * 73 * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType struct. 74 * 75 */ 76 typedef enum { 77 PS_DIMEN_SCALAR, ///< Scalar. 78 PS_DIMEN_VECTOR, ///< Vector. 79 PS_DIMEN_TRANSV, ///< Transposed vector. 80 PS_DIMEN_IMAGE, ///< Image. 81 PS_DIMEN_OTHER ///< Something else that's not supported for arithmetic. 82 } psDimen; 83 84 /** The type of a data type. 85 * 86 * All psLib complex types consist of primitive components. This struct provides the description of those 87 * primitives. 88 * 89 */ 90 typedef struct 91 { 92 psElemType type; ///< Primitive type. 93 psDimen dimen; ///< Dimensionality. 94 } 95 psType; 30 #include "psType.h" 96 31 97 32 /** An vector to support primitive types. … … 174 109 * 175 110 */ 176 void psV oidPtrVectorFree(111 void psVectorElementFree( 177 112 psVector *restrict psVec, ///< Void pointer vector to destroy. 178 113 void (*elemFree)(void *) ///< Optional callback function to remove vector elements. -
trunk/psLib/src/mathtypes/psVector.c
r670 r672 19 19 * @author Ross Harman, MHPCC 20 20 * 21 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $22 * @date $Date: 2004-05-13 2 2:47:52$21 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2004-05-13 23:36:27 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 } 76 76 77 if (elemType == PS_TYPE_PTR) { 78 elementSize = sizeof(void*); 79 } else { 80 elementSize = PSELEMTYPE_SIZEOF(elemType); 81 } 77 elementSize = PSELEMTYPE_SIZEOF(elemType); 82 78 83 79 // Create vector struct … … 102 98 // Invalid nalloc 103 99 if(nalloc < 1) { 104 psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);100 psError(__func__, "Invalid value for nalloc (%d)\n", nalloc); 105 101 return NULL; 106 102 } 107 103 108 if (elemType == PS_TYPE_PTR) { 109 elementSize = sizeof(void*); 110 } else { 111 elementSize = PSELEMTYPE_SIZEOF(elemType); 112 } 104 elementSize = PSELEMTYPE_SIZEOF(elemType); 113 105 114 106 … … 137 129 } 138 130 139 if (psVec->type.type == PS_TYPE_PTR) { 140 psLogMsg(__func__,PS_LOG_WARN,"psVectorFree was called with a void* vector. " 141 "Referenced of pointers was not freed."); 142 psVoidPtrVectorFree(psVec,NULL); 143 } else { 144 psFree(psVec->vec.v); 145 psFree(psVec); 146 } 131 psFree(psVec->vec.v); 132 psFree(psVec); 147 133 } 148 134 -
trunk/psLib/src/mathtypes/psVector.h
r670 r672 3 3 * @brief Contains support for basic vector types 4 4 * 5 * This file defines types and functions for one dimensional vectors which include: 5 * This file defines types and functions for one dimensional vectors which include: 6 6 * char 7 7 * short … … 18 18 * 19 19 * @author Ross Harman, MHPCC 20 * 21 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $22 * @date $Date: 2004-05-13 2 2:47:52$20 * 21 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2004-05-13 23:36:27 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #define PS_VECTOR_H 29 29 30 #include <complex.h> 31 #include <stdint.h> 32 33 /******************************************************************************/ 34 /* DEFINE STATEMENTS */ 35 /******************************************************************************/ 36 37 // None 38 39 /******************************************************************************/ 40 /* TYPE DEFINITIONS */ 41 /******************************************************************************/ 42 43 /** Basic data types used by the containers. 44 * 45 * The basic types of the primitives used by psLib are defined within this enum. This enum is in turn used by 46 * the psType struct. 47 * 48 */ 49 typedef enum { 50 PS_TYPE_INT8 = 0x11, ///< Character. 51 PS_TYPE_INT16 = 0x12, ///< Short integer. 52 PS_TYPE_INT32 = 0x14, ///< Integer. 53 PS_TYPE_INT64 = 0x18, ///< Long integer. 54 PS_TYPE_UINT8 = 0x31, ///< Unsigned character. 55 PS_TYPE_UINT16 = 0x32, ///< Unsigned short integer. 56 PS_TYPE_UINT32 = 0x34, ///< Unsigned integer. 57 PS_TYPE_UINT64 = 0x38, ///< Unsigned long integer. 58 PS_TYPE_FLOAT = 0x44, ///< Single-precision Floating point. 59 PS_TYPE_DOUBLE = 0x48, ///< Double-precision floating point. 60 PS_TYPE_COMPLEX_FLOAT = 0x84, ///< Complex numbers consisting of single-precision floating point. 61 PS_TYPE_COMPLEX_DOUBLE = 0x88, ///< Complex numbers consisting of double-precision floating point. 62 PS_TYPE_PTR = 0x00, ///< Something else that's not supported for arithmetic.} 63 } psElemType; 64 65 #define IS_PSELEMTYPE_INT(x) (x & 0x10 == 0x10) 66 #define IS_PSELEMTYPE_UNSIGNED(x) (x & 0x20 == 0x20) 67 #define IS_PSELEMTYPE_REAL(x) (x & 0x40 == 0x40) 68 #define IS_PSELEMTYPE_COMPLEX(x) (x & 0x80 == 0x80) 69 #define PSELEMTYPE_SIZEOF(x) (x & 0x0F) 70 71 /** Dimensions of a data type. 72 * 73 * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType struct. 74 * 75 */ 76 typedef enum { 77 PS_DIMEN_SCALAR, ///< Scalar. 78 PS_DIMEN_VECTOR, ///< Vector. 79 PS_DIMEN_TRANSV, ///< Transposed vector. 80 PS_DIMEN_IMAGE, ///< Image. 81 PS_DIMEN_OTHER ///< Something else that's not supported for arithmetic. 82 } psDimen; 83 84 /** The type of a data type. 85 * 86 * All psLib complex types consist of primitive components. This struct provides the description of those 87 * primitives. 88 * 89 */ 90 typedef struct 91 { 92 psElemType type; ///< Primitive type. 93 psDimen dimen; ///< Dimensionality. 94 } 95 psType; 30 #include "psType.h" 96 31 97 32 /** An vector to support primitive types. … … 174 109 * 175 110 */ 176 void psV oidPtrVectorFree(111 void psVectorElementFree( 177 112 psVector *restrict psVec, ///< Void pointer vector to destroy. 178 113 void (*elemFree)(void *) ///< Optional callback function to remove vector elements.
Note:
See TracChangeset
for help on using the changeset viewer.
