Changeset 11698
- Timestamp:
- Feb 7, 2007, 4:59:36 PM (19 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 2 edited
-
psVector.c (modified) (6 diffs)
-
psVector.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psVector.c
r11697 r11698 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.9 3$ $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 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 153 153 } 154 154 155 psVector* psVectorRecycle(psVector* vector, 156 long nalloc, 157 psElemType type) 155 psVector* p_psVectorRecycle(const char *file, 156 unsigned int lineno, 157 const char *func, 158 psVector* vector, 159 long nalloc, 160 psElemType type) 158 161 { 159 162 psS32 byteSize; 160 163 161 164 if (vector == NULL) { 162 return p sVectorAlloc(nalloc, type);165 return p_psVectorAlloc(file, lineno, func, nalloc, type); 163 166 } 164 167 … … 224 227 } 225 228 226 psVector* psVectorCopy(psVector* output, 229 psVector* p_psVectorCopy(const char *file, 230 unsigned int lineno, 231 const char *func, 232 psVector* output, 227 233 const psVector* input, 228 234 psElemType type) … … 237 243 psS32 nElements = input->n; 238 244 239 output = p sVectorRecycle(output, nElements, type);245 output = p_psVectorRecycle(file, lineno, func, output, nElements, type); 240 246 if (nElements == 0) { 241 247 // psWarning("Warning: psVector was copied with 0 elements!\n"); … … 854 860 855 861 #define FUNC_MACRO_VECTOR_CREATE(TYPE) \ 856 static psVector *vectorCreate##TYPE( psVector *input, double lower, double upper, double delta) \862 static psVector *vectorCreate##TYPE(const char *file, unsigned int lineno, const char *func, psVector *input, double lower, double upper, double delta) \ 857 863 { \ 858 864 \ 859 865 int nBin = (upper - lower) / delta; \ 860 psVector *vec = p sVectorRecycle(input, nBin, PS_TYPE_##TYPE); \866 psVector *vec = p_psVectorRecycle(file, lineno, func, input, nBin, PS_TYPE_##TYPE); \ 861 867 vec->n = nBin; \ 862 868 for (int i = 0; i < nBin; i++) \ … … 878 884 FUNC_MACRO_VECTOR_CREATE(F64) 879 885 880 psVector *psVectorCreate (psVector *input, 881 double lower, 882 double upper, 883 double delta, 884 psElemType type) 886 psVector *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) 885 894 { 886 895 psVector *out = NULL; 887 896 switch (type) { 888 897 case PS_TYPE_S8: 889 out = vectorCreateS8( input, lower, upper, delta);898 out = vectorCreateS8(file, lineno, func, input, lower, upper, delta); 890 899 break; 891 900 case PS_TYPE_S16: 892 out = vectorCreateS16( input, lower, upper, delta);901 out = vectorCreateS16(file, lineno, func, input, lower, upper, delta); 893 902 break; 894 903 case PS_TYPE_S32: 895 out = vectorCreateS32( input, lower, upper, delta);904 out = vectorCreateS32(file, lineno, func, input, lower, upper, delta); 896 905 break; 897 906 case PS_TYPE_S64: 898 out = vectorCreateS64( input, lower, upper, delta);907 out = vectorCreateS64(file, lineno, func, input, lower, upper, delta); 899 908 break; 900 909 case PS_TYPE_U8: 901 out = vectorCreateU8( input, lower, upper, delta);910 out = vectorCreateU8(file, lineno, func, input, lower, upper, delta); 902 911 break; 903 912 case PS_TYPE_U16: 904 out = vectorCreateU16( input, lower, upper, delta);913 out = vectorCreateU16(file, lineno, func, input, lower, upper, delta); 905 914 break; 906 915 case PS_TYPE_U32: 907 out = vectorCreateU32( input, lower, upper, delta);916 out = vectorCreateU32(file, lineno, func, input, lower, upper, delta); 908 917 break; 909 918 case PS_TYPE_U64: 910 out = vectorCreateU64( input, lower, upper, delta);919 out = vectorCreateU64(file, lineno, func, input, lower, upper, delta); 911 920 break; 912 921 case PS_TYPE_F32: 913 out = vectorCreateF32( input, lower, upper, delta);922 out = vectorCreateF32(file, lineno, func, input, lower, upper, delta); 914 923 break; 915 924 case PS_TYPE_F64: 916 out = vectorCreateF64( input, lower, upper, delta);925 out = vectorCreateF64(file, lineno, func, input, lower, upper, delta); 917 926 break; 918 927 default: -
trunk/psLib/src/mathtypes/psVector.h
r11697 r11698 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.6 4$ $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 $ 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 15 15 */ … … 54 54 #define P_PSVECTOR_SET_NALLOC(vec,n) *(long*)&(vec->nalloc) = n 55 55 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 */ 70 bool psMemCheckVector( 71 psPtr ptr ///< the pointer whose type to check 72 ) 73 ; 72 74 73 75 /** Allocate a vector, with length set to number allocated … … 169 171 * 170 172 */ 173 #ifdef DOXYGEN 171 174 psVector* psVectorRecycle( 172 175 psVector* vector, … … 174 177 ///< taken to preserve the values. 175 178 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 183 psVector* 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 179 197 180 198 … … 187 205 * 188 206 */ 207 #ifdef DOXYGEN 189 208 psVector* psVectorCopy( 190 209 psVector* output, ///< if non-NULL, a psVector to recycle … … 192 211 psElemType type ///< the data type of the resulting psVector 193 212 ); 213 #else // ifdef DOXYGEN 214 psVector* 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 194 225 195 226 … … 244 275 * @return bool TRUE is successful, otherwise FALSE. 245 276 */ 246 bool p_psVectorPrint (277 bool p_psVectorPrint( 247 278 int fd, ///< output file descriptor 248 279 const psVector *a, ///< vector to print … … 272 303 * @return psVector*: the newly created psVector 273 304 */ 274 psVector *psVectorCreate ( 305 #ifdef DOXYGEN 306 psVector *psVectorCreate( 275 307 psVector *input, ///< Input vector 276 308 double lower, ///< lower bound … … 279 311 psElemType type ///< type of vector to create 280 312 ); 313 #else // ifdef DOXYGEN 314 psVector *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 281 327 282 328
Note:
See TracChangeset
for help on using the changeset viewer.
