Changeset 11696
- Timestamp:
- Feb 7, 2007, 4:31:59 PM (19 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 2 edited
-
psVector.c (modified) (5 diffs)
-
psVector.h (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psVector.c
r11668 r11696 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.9 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-02-0 6 21:36:09 $11 * @version $Revision: 1.92 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-02-08 02:31:59 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 73 73 74 74 // Allocate a psVector; does not set vector->n (left to the caller) 75 static psVector *vectorAlloc(long nalloc, // Number of elements to allocate 76 psElemType type // Type of elements 77 ) 75 static psVector *vectorAlloc(const char *file, 76 unsigned int lineno, 77 const char *func, 78 long nalloc, // Number of elements to allocate 79 psElemType type) // Type of elements 78 80 { 79 81 int elementSize = PSELEMTYPE_SIZEOF(type); // Size, in bytes, of element … … 85 87 86 88 // Create vector struct 87 psVector *vector = (psVector*) p sAlloc(sizeof(psVector));89 psVector *vector = (psVector*) p_psAlloc(file, lineno, func, sizeof(psVector)); 88 90 psMemSetDeallocator(vector, (psFreeFunc) vectorFree); 89 91 … … 98 100 } 99 101 100 psVector* psVectorAlloc(long nalloc, 101 psElemType type) 102 { 103 psVector *vector = vectorAlloc(nalloc, type); 102 psVector* p_psVectorAlloc(const char *file, 103 unsigned int lineno, 104 const char *func, 105 long nalloc, 106 psElemType type) 107 { 108 psVector *vector = vectorAlloc(file, lineno, func, nalloc, type); 104 109 if (!vector) { 105 110 return NULL; … … 109 114 } 110 115 111 psVector* psVectorAllocEmpty(long nalloc, 112 psElemType type) 113 { 114 psVector *vector = vectorAlloc(nalloc, type); 116 psVector* p_psVectorAllocEmpty(const char *file, 117 unsigned int lineno, 118 const char *func, 119 long nalloc, 120 psElemType type) 121 { 122 psVector *vector = vectorAlloc(file, lineno, func, nalloc, type); 115 123 if (!vector) { 116 124 return NULL; -
trunk/psLib/src/mathtypes/psVector.h
r11668 r11696 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.6 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-02-0 6 21:36:09 $11 * @version $Revision: 1.63 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-02-08 02:31:59 $ 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 14 14 */ … … 77 77 * @return psVector* Pointer to psVector. 78 78 */ 79 #ifdef DOXYGEN 79 80 psVector* psVectorAlloc( 80 81 long nalloc, ///< Total number of elements to make available. 81 82 psElemType type ///< Type of data to be held by vector. 82 83 ); 84 #else // ifdef DOXYGEN 85 psVector* p_psVectorAlloc( 86 const char *file, ///< File of caller 87 unsigned int lineno, ///< Line number of caller 88 const char *func, ///< Function name of caller 89 long nalloc, ///< Total number of elements to make available. 90 psElemType type ///< Type of data to be held by vector. 91 //#ifdef __GNUC__ 92 //) __attribute__((malloc)); 93 //#else // ifdef __GNUC__ 94 ); 95 //#endif // ifdef __GNUC__ 96 #define psVectorAlloc(nalloc, type) \ 97 p_psVectorAlloc(__FILE__, __LINE__, __func__, nalloc, type) 98 #endif // ifdef DOXYGEN 99 83 100 84 101 /** Allocate a vector, with length set to zero … … 89 106 * @return psVector* Pointer to psVector. 90 107 */ 108 #ifdef DOXYGEN 91 109 psVector* psVectorAllocEmpty( 92 110 long nalloc, ///< Total number of elements to make available. 93 111 psElemType type ///< Type of data to be held by vector. 94 112 ); 113 #else // ifdef DOXYGEN 114 psVector* p_psVectorAllocEmpty( 115 const char *file, ///< File of caller 116 unsigned int lineno, ///< Line number of caller 117 const char *func, ///< Function name of caller 118 long nalloc, ///< Total number of elements to make available. 119 psElemType type ///< Type of data to be held by vector. 120 //#ifdef __GNUC__ 121 //) __attribute__((malloc)); 122 //#else // ifdef __GNUC__ 123 ); 124 //#endif // ifdef __GNUC__ 125 #define psVectorAllocEmpty(nalloc, type) \ 126 p_psVectorAllocEmpty(__FILE__, __LINE__, __func__, nalloc, type) 127 #endif // ifdef DOXYGEN 128 95 129 96 130 /** Reallocate a vector. … … 107 141 long nalloc ///< Total number of elements to make available. 108 142 ); 143 109 144 110 145 /** Extend a vector's length. … … 123 158 ); 124 159 160 125 161 /** Recycle a vector. 126 162 * … … 141 177 ); 142 178 179 143 180 /** Copy a vector, converting types. 144 181 * … … 155 192 ); 156 193 194 157 195 /** Sort an array of floats. 158 196 * … … 167 205 ); 168 206 207 169 208 /** Creates an array of indices based on sort ordered of array. 170 209 * … … 179 218 ); 180 219 220 181 221 /** Creates a string from a psVector's values in the form "[x0,x1,x2]". 182 222 * … … 188 228 ); 189 229 230 190 231 /** Returns an element in the vector as a psF64 value 191 232 * … … 196 237 int position ///< the vector position to get 197 238 ); 239 198 240 199 241 /** Print a vector to a stream … … 207 249 ); 208 250 251 209 252 /** Initializes the vector with the given value. 210 253 * 211 * The input data is cast to match the vector datatype, allowing for integers to be preserved. 254 * The input data is cast to match the vector datatype, allowing for integers 255 * to be preserved. 212 256 * 213 257 * @return bool: True if successful, otherwise false. … … 218 262 ); 219 263 264 220 265 /** Creates a new vector, or reallocates the provided vector if input is not NULL. 221 266 * 222 * The created vector consists of the data range starting at lower, running to upper,223 * in steps of delta. The upper-end value is exclusive; the sequence is equivalent to224 * for (x = lower; x <= upper - 1; x += delta).267 * The created vector consists of the data range starting at lower, running to 268 * upper, in steps of delta. The upper-end value is exclusive; the sequence 269 * is equivalent to for (x = lower; x <= upper - 1; x += delta). 225 270 * 226 271 * @return psVector*: the newly created psVector … … 234 279 ); 235 280 281 236 282 /** Sets the value of the input vector at the specified position to value. 237 283 * … … 246 292 ); 247 293 294 248 295 /** Returns the value of the input vector at the specified position. 249 296 * … … 257 304 ); 258 305 306 259 307 /** Returns the number of pixels in the vector which satisfy any of the mask bits. 260 308 * 261 * An error (eg, invalid vector) results in a return value of -1. The vector must be U8. 309 * An error (eg, invalid vector) results in a return value of -1. The vector 310 * must be U8. 262 311 * 263 312 * @return long: the number of pixels counted … … 267 316 psMaskType value ///< the mask value to satisfy 268 317 ); 318 269 319 270 320 /** Get the number of elements in use from a specified psVector. (vector.n)
Note:
See TracChangeset
for help on using the changeset viewer.
