Changeset 4212 for trunk/psLib/src/mathtypes
- Timestamp:
- Jun 10, 2005, 11:46:46 AM (21 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 2 edited
-
psVector.c (modified) (3 diffs)
-
psVector.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psVector.c
r3786 r4212 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 4-29 02:25:09$11 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-10 21:46:46 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 55 55 elementSize = PSELEMTYPE_SIZEOF(elemType); 56 if (elementSize < 1) { 57 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 58 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, elemType); 59 return NULL; 60 } 61 56 62 57 63 // Create vector struct … … 121 127 in->n = n; 122 128 return in; 129 } 130 131 psVector *psVectorExtend(psVector *vector, int delta, int nExtend) 132 { 133 // can't handle a NULL vector (don't know the data type to allocate) 134 if (vector == NULL) { 135 psError(PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psVector_NULL); 137 return NULL; 138 } 139 140 // requirement on delta; if < 1, set to 10. 141 if (delta < 1) { 142 delta = 10; 143 } 144 145 // adjust the allocated size, if needed. (if nExtend < 1, this is will never happen) 146 if (nExtend > 0) { 147 unsigned int minAlloc = vector->n + nExtend + nExtend; 148 if (vector->nalloc < minAlloc) { 149 unsigned int nAlloc = delta + vector->nalloc; 150 // make sure the delta is large enough hold twice the extended length. 151 if (nAlloc < minAlloc) { 152 nAlloc = minAlloc; 153 } 154 vector = psVectorRealloc(vector, nAlloc); 155 } 156 } else if (nExtend < -vector->n) { 157 // For the case of a negative nExtend, need to check that we are not decreasing 158 // vector beyond its own length (i.e., creating a negative length). 159 nExtend = -vector->n; 160 } 161 162 // increment the length by the value specified 163 vector->n += nExtend; 164 165 return vector; 123 166 } 124 167 -
trunk/psLib/src/mathtypes/psVector.h
r4162 r4212 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06- 08 23:40:45$13 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-10 21:46:46 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 88 88 psVector* psVec, ///< Vector to reallocate. 89 89 psU32 nalloc ///< Total number of elements to make available. 90 ); 91 92 /** Extend a vector's length. 93 * 94 * Increments a vector's length, n, by the specified number of elements. 95 * If the allocated storage is less than the current vector's length plus 96 * twice the number of elements to be added, it is reallocated larger by 97 * a given amount. 98 * 99 * @return psVector* Pointer to the adjusted psVector 100 */ 101 psVector *psVectorExtend( 102 psVector *vector, ///< Vector to extend 103 int delta, ///< Amount to expand allocation, if necessary 104 int nExtend ///< Number of elements to add to vector length 90 105 ); 91 106
Note:
See TracChangeset
for help on using the changeset viewer.
