Changeset 4409 for trunk/psLib/src/mathtypes
- Timestamp:
- Jun 28, 2005, 10:17:52 AM (21 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 6 edited
-
psImage.c (modified) (2 diffs)
-
psImage.h (modified) (2 diffs)
-
psScalar.c (modified) (4 diffs)
-
psScalar.h (modified) (2 diffs)
-
psVector.c (modified) (5 diffs)
-
psVector.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r4392 r4409 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.7 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-06-2 5 02:02:05$11 * @version $Revision: 1.72 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-28 20:17:52 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 137 137 } 138 138 139 char* psRegionToString(psRegion region)139 psString psRegionToString(const psRegion region) 140 140 { 141 141 char tmpText[256]; // big enough to store any region as text -
trunk/psLib/src/mathtypes/psImage.h
r4330 r4409 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06-2 1 03:01:37$13 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-28 20:17:52 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 132 132 /** Create a string of the standard IRAF form '[x0:x1,y0:y1]' from a psRegion. 133 133 * 134 * @return char*: A new string representing the psRegion as text, or NULL134 * @return psString: A new string representing the psRegion as text, or NULL 135 135 * is not successful. 136 136 */ 137 char*psRegionToString(138 psRegion region///< the psRegion to convert to a string137 psString psRegionToString( 138 const psRegion region ///< the psRegion to convert to a string 139 139 ); 140 140 -
trunk/psLib/src/mathtypes/psScalar.c
r4330 r4409 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-06-2 1 03:01:37$10 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-06-28 20:17:52 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 #include "psCollectionsErrors.h" 23 23 24 psScalar* psScalarAlloc( psC64 value, psElemType dataType)24 psScalar* psScalarAlloc(complex value, psElemType type) 25 25 { 26 26 psScalar* scalar = NULL; … … 30 30 31 31 scalar->type.dimen = PS_DIMEN_SCALAR; 32 scalar->type.type = dataType;32 scalar->type.type = type; 33 33 34 switch ( dataType) {34 switch (type) { 35 35 case PS_TYPE_S8: 36 36 scalar->data.S8 = (psS8) value; … … 72 72 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 73 73 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 74 dataType);74 type); 75 75 psFree(scalar); 76 76 return NULL; -
trunk/psLib/src/mathtypes/psScalar.h
r4330 r4409 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06-2 1 03:01:37$13 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-28 20:17:52 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 66 66 */ 67 67 psScalar* psScalarAlloc( 68 psC64 value,///< Data to be put into psScalar.69 psElemType dataType///< Type of data to be held by psScalar.68 complex value, ///< Data to be put into psScalar. 69 psElemType type ///< Type of data to be held by psScalar. 70 70 ); 71 71 -
trunk/psLib/src/mathtypes/psVector.c
r4392 r4409 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-06-2 5 02:02:05$11 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-28 20:17:52 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 48 48 // FUNCTION IMPLEMENTATION - PUBLIC 49 49 50 psVector* psVectorAlloc( psU32 nalloc, psElemType elemType)50 psVector* psVectorAlloc(unsigned long nalloc, psElemType type) 51 51 { 52 52 psVector* psVec = NULL; 53 53 psS32 elementSize = 0; 54 54 55 elementSize = PSELEMTYPE_SIZEOF( elemType);55 elementSize = PSELEMTYPE_SIZEOF(type); 56 56 if (elementSize < 1) { 57 57 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 58 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, elemType);58 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, type); 59 59 return NULL; 60 60 } … … 66 66 67 67 psVec->type.dimen = PS_DIMEN_VECTOR; 68 psVec->type.type = elemType;68 psVec->type.type = type; 69 69 *(int*)&psVec->nalloc = nalloc; 70 70 psVec->n = nalloc; … … 76 76 } 77 77 78 psVector* psVectorRealloc(psVector* in, psU32nalloc)78 psVector* psVectorRealloc(psVector* vector, unsigned long nalloc) 79 79 { 80 80 psS32 elementSize = 0; 81 81 psElemType elemType; 82 82 83 if ( in== NULL) {83 if (vector == NULL) { 84 84 psError(PS_ERR_BAD_PARAMETER_NULL, true, 85 85 PS_ERRORTEXT_psVector_REALLOC_NULL); 86 86 return NULL; 87 } else if ( in->nalloc != nalloc) { // No need to realloc to same size88 elemType = in->type.type;87 } else if (vector->nalloc != nalloc) { // No need to realloc to same size 88 elemType = vector->type.type; 89 89 elementSize = PSELEMTYPE_SIZEOF(elemType); 90 if (nalloc < in->n) {91 in->n = nalloc;90 if (nalloc < vector->n) { 91 vector->n = nalloc; 92 92 } 93 93 // Realloc after decrementation to avoid accessing freed array elements 94 in->data.U8 = psRealloc(in->data.U8, nalloc * elementSize);95 *(int*)& in->nalloc = nalloc;96 } 97 98 return in;99 } 100 101 psVector* psVectorRecycle(psVector* in, psU32 n, psElemType type)94 vector->data.U8 = psRealloc(vector->data.U8, nalloc * elementSize); 95 *(int*)&vector->nalloc = nalloc; 96 } 97 98 return vector; 99 } 100 101 psVector* psVectorRecycle(psVector* vector, unsigned long nalloc, psElemType type) 102 102 { 103 103 psS32 byteSize; 104 104 105 if ( in== NULL) {106 return psVectorAlloc(n , type);107 } 108 109 if ( in->type.dimen != PS_DIMEN_VECTOR &&110 in->type.dimen != PS_DIMEN_TRANSV) {111 psFree( in);105 if (vector == NULL) { 106 return psVectorAlloc(nalloc, type); 107 } 108 109 if (vector->type.dimen != PS_DIMEN_VECTOR && 110 vector->type.dimen != PS_DIMEN_TRANSV) { 111 psFree(vector); 112 112 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 113 113 PS_ERRORTEXT_psVector_NOT_A_VECTOR); … … 115 115 } 116 116 117 byteSize = n * PSELEMTYPE_SIZEOF(type);117 byteSize = nalloc * PSELEMTYPE_SIZEOF(type); 118 118 119 119 // need to increase data buffer? 120 if (byteSize > in->nalloc*PSELEMTYPE_SIZEOF(in->type.type)) {121 in->data.U8 = psRealloc(in->data.U8, byteSize);122 *(int*)& in->nalloc = n;123 } 124 125 in->type.dimen = PS_DIMEN_VECTOR;126 in->type.type = type;127 in->n = n;128 return in;120 if (byteSize > vector->nalloc*PSELEMTYPE_SIZEOF(vector->type.type)) { 121 vector->data.U8 = psRealloc(vector->data.U8, byteSize); 122 *(int*)&vector->nalloc = nalloc; 123 } 124 125 vector->type.dimen = PS_DIMEN_VECTOR; 126 vector->type.type = type; 127 vector->n = nalloc; 128 return vector; 129 129 } 130 130 -
trunk/psLib/src/mathtypes/psVector.h
r4330 r4409 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06-2 1 03:01:37$13 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-28 20:17:52 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 29 ///< Union of psVector data types. 30 30 typedef union { 31 psU8* U8; ///< Unsigned 8-bit integer data. 32 psU16* U16; ///< Unsigned 16-bit integer data. 33 psU32* U32; ///< Unsigned 32-bit integer data. 34 psU64* U64; ///< Unsigned 64-bit integer data. 35 psS8* S8; ///< Signed 8-bit integer data. 36 psS16* S16; ///< Signed 16-bit integer data. 37 psS32* S32; ///< Signed 32-bit integer data. 38 psS64* S64; ///< Signed 64-bit integer data. 39 psF32* F32; ///< Single-precision float data. 40 psF64* F64; ///< Double-precision float data. 41 psC32* C32; ///< Single-precision complex data. 42 psC64* C64; ///< Double-precision complex data. 43 } p_psVectorData; 31 psU8* U8; ///< Unsigned 8-bit integer data. 32 psU16* U16; ///< Unsigned 16-bit integer data. 33 psU32* U32; ///< Unsigned 32-bit integer data. 34 psU64* U64; ///< Unsigned 64-bit integer data. 35 psS8* S8; ///< Signed 8-bit integer data. 36 psS16* S16; ///< Signed 16-bit integer data. 37 psS32* S32; ///< Signed 32-bit integer data. 38 psS64* S64; ///< Signed 64-bit integer data. 39 psF32* F32; ///< Single-precision float data. 40 psF64* F64; ///< Double-precision float data. 41 psC32* C32; ///< Single-precision complex data. 42 psC64* C64; ///< Double-precision complex data. 43 } 44 p_psVectorData; 44 45 45 46 /** An vector to support primitive types. … … 50 51 typedef struct 51 52 { 52 psType type; ///< Type of data.53 int n; ///< Number of elements in use.54 const int nalloc; ///< Total number of elements available.55 p_psVectorData data; ///< Union for data types.53 psType type; ///< Type of data. 54 int n; ///< Number of elements in use. 55 const int nalloc; ///< Total number of elements available. 56 p_psVectorData data; ///< Union for data types. 56 57 } 57 58 psVector; … … 72 73 */ 73 74 psVector* psVectorAlloc( 74 psU32 nalloc,///< Total number of elements to make available.75 psElemType dataType///< Type of data to be held by vector.75 unsigned long nalloc, ///< Total number of elements to make available. 76 psElemType type ///< Type of data to be held by vector. 76 77 ); 77 78 … … 86 87 */ 87 88 psVector* psVectorRealloc( 88 psVector* psVec,///< Vector to reallocate.89 psU32 nalloc///< Total number of elements to make available.89 psVector* vector, ///< Vector to reallocate. 90 unsigned long nalloc ///< Total number of elements to make available. 90 91 ); 91 92 … … 115 116 */ 116 117 psVector* psVectorRecycle( 117 psVector* psVec,118 psVector* vector, 118 119 ///< Vector to recycle. If NULL, a new vector is created. No effort 119 120 ///< taken to preserve the values. 120 121 121 psU32 nalloc,///< Total number of elements to make available.122 unsigned long nalloc, ///< Total number of elements to make available. 122 123 psElemType type ///< the datatype of the returned vector 123 124 );
Note:
See TracChangeset
for help on using the changeset viewer.
