Changeset 679
- Timestamp:
- May 13, 2004, 3:12:59 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
dataManip/psStats.c (modified) (11 diffs)
-
math/psStats.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psStats.c
r674 r679 166 166 if (maskVector != NULL) { 167 167 for (i=0;i<myVector->n;i++) { 168 if (!(maskVal & maskVector->vec. i32[i])) {168 if (!(maskVal & maskVector->vec.ui8[i])) { 169 169 mean+= myVector->vec.f[i]; 170 170 count++; … … 172 172 } 173 173 mean/= (float) count; 174 return(mean);175 174 } else { 176 175 for (i=0;i<myVector->n;i++) { 177 176 mean+= myVector->vec.f[i]; 178 177 } 179 }180 mean/= myVector->n;178 mean/= (float) myVector->n; 179 } 181 180 return(mean); 182 181 } … … 189 188 float max = -1e99; 190 189 190 printf("COOL: p_psArrayMax()\n"); 191 191 if (maskVector != NULL) { 192 192 for (i=0;i<myVector->n;i++) { 193 if (!(maskVal & maskVector->vec. i32[i])) {193 if (!(maskVal & maskVector->vec.ui8[i])) { 194 194 if (myVector->vec.f[i] > max) { 195 max = m askVector->vec.i32[i];195 max = myVector->vec.f[i]; 196 196 } 197 197 } … … 200 200 for (i=0;i<myVector->n;i++) { 201 201 if (myVector->vec.f[i] > max) { 202 max = m askVector->vec.i32[i];202 max = myVector->vec.f[i]; 203 203 } 204 204 } … … 216 216 if (maskVector != NULL) { 217 217 for (i=0;i<myVector->n;i++) { 218 if (!(maskVal & maskVector->vec. i32[i])) {218 if (!(maskVal & maskVector->vec.ui8[i])) { 219 219 if (myVector->vec.f[i] < min) { 220 min = m askVector->vec.i32[i];220 min = myVector->vec.f[i]; 221 221 } 222 222 } … … 225 225 for (i=0;i<myVector->n;i++) { 226 226 if (myVector->vec.f[i] < min) { 227 min = m askVector->vec.i32[i];227 min = myVector->vec.f[i]; 228 228 } 229 229 } … … 244 244 if (maskVector != NULL) { 245 245 for (i=0;i<myVector->n;i++) { 246 if (!(maskVal & maskVector->vec. i32[i])) {246 if (!(maskVal & maskVector->vec.ui8[i])) { 247 247 numData++; 248 248 } … … 277 277 if (maskVector != NULL) { 278 278 for (i=0;i<myVector->n;i++) { 279 if (!(maskVal & maskVector->vec. i32[i])) {279 if (!(maskVal & maskVector->vec.ui8[i])) { 280 280 unsortedVector->vec.f[count++] = maskVector->vec.f[i]; 281 281 } … … 319 319 } 320 320 321 psStats *psArrayStats(const psVector *restrict myVector, // FLOAT 322 const psVector *restrict maskVector, // INT 321 /****************************************************************************** 322 323 NOTE: The current strategy is to implement everything assuming that all 324 input data is of type PS_TYPE_FLOAT. Once the basic code is in place, 325 we will macro-ize everything and add PS_TYPE_UINT16 and PS_TYPE_DOUBLE. 326 327 *****************************************************************************/ 328 psStats *psArrayStats(const psVector *restrict myVector, 329 const psVector *restrict maskVector, 323 330 unsigned int maskVal, 324 331 psStats *stats) … … 328 335 newStruct = psStatsAlloc(stats->options); 329 336 if (myVector == NULL) { 330 ps Error(__func__,337 psAbort(__func__, 331 338 "Input data array (myVector) was NULL."); 332 339 } 333 340 334 if ((maskVector != NULL) && 335 (myVector->n != maskVector->n)) { 336 psError(__func__, "Vector data and vector mask are of different sizes."); 341 if (myVector->type.type != PS_TYPE_FLOAT) { 342 psAbort(__func__, 343 "Only data type PS_TYPE_FLOAT is currently supported."); 344 } 345 346 if (maskVector != NULL) { 347 if (myVector->n != maskVector->n) { 348 psAbort(__func__, 349 "Vector data and vector mask are of different sizes."); 350 } 351 if (maskVector->type.type != PS_TYPE_UINT8) { 352 psAbort(__func__, 353 "Vector mask must be type PS_TYPE_UINT8"); 354 } 337 355 } 338 356 … … 426 444 // OLD CODE: Should we check for an unknown option? 427 445 // default: 428 // ps Error(__func__, "Unknown options 0x%x.\n", stats->options);446 // psAbort(__func__, "Unknown options 0x%x.\n", stats->options); 429 447 430 448 return(newStruct); -
trunk/psLib/src/math/psStats.c
r674 r679 166 166 if (maskVector != NULL) { 167 167 for (i=0;i<myVector->n;i++) { 168 if (!(maskVal & maskVector->vec. i32[i])) {168 if (!(maskVal & maskVector->vec.ui8[i])) { 169 169 mean+= myVector->vec.f[i]; 170 170 count++; … … 172 172 } 173 173 mean/= (float) count; 174 return(mean);175 174 } else { 176 175 for (i=0;i<myVector->n;i++) { 177 176 mean+= myVector->vec.f[i]; 178 177 } 179 }180 mean/= myVector->n;178 mean/= (float) myVector->n; 179 } 181 180 return(mean); 182 181 } … … 189 188 float max = -1e99; 190 189 190 printf("COOL: p_psArrayMax()\n"); 191 191 if (maskVector != NULL) { 192 192 for (i=0;i<myVector->n;i++) { 193 if (!(maskVal & maskVector->vec. i32[i])) {193 if (!(maskVal & maskVector->vec.ui8[i])) { 194 194 if (myVector->vec.f[i] > max) { 195 max = m askVector->vec.i32[i];195 max = myVector->vec.f[i]; 196 196 } 197 197 } … … 200 200 for (i=0;i<myVector->n;i++) { 201 201 if (myVector->vec.f[i] > max) { 202 max = m askVector->vec.i32[i];202 max = myVector->vec.f[i]; 203 203 } 204 204 } … … 216 216 if (maskVector != NULL) { 217 217 for (i=0;i<myVector->n;i++) { 218 if (!(maskVal & maskVector->vec. i32[i])) {218 if (!(maskVal & maskVector->vec.ui8[i])) { 219 219 if (myVector->vec.f[i] < min) { 220 min = m askVector->vec.i32[i];220 min = myVector->vec.f[i]; 221 221 } 222 222 } … … 225 225 for (i=0;i<myVector->n;i++) { 226 226 if (myVector->vec.f[i] < min) { 227 min = m askVector->vec.i32[i];227 min = myVector->vec.f[i]; 228 228 } 229 229 } … … 244 244 if (maskVector != NULL) { 245 245 for (i=0;i<myVector->n;i++) { 246 if (!(maskVal & maskVector->vec. i32[i])) {246 if (!(maskVal & maskVector->vec.ui8[i])) { 247 247 numData++; 248 248 } … … 277 277 if (maskVector != NULL) { 278 278 for (i=0;i<myVector->n;i++) { 279 if (!(maskVal & maskVector->vec. i32[i])) {279 if (!(maskVal & maskVector->vec.ui8[i])) { 280 280 unsortedVector->vec.f[count++] = maskVector->vec.f[i]; 281 281 } … … 319 319 } 320 320 321 psStats *psArrayStats(const psVector *restrict myVector, // FLOAT 322 const psVector *restrict maskVector, // INT 321 /****************************************************************************** 322 323 NOTE: The current strategy is to implement everything assuming that all 324 input data is of type PS_TYPE_FLOAT. Once the basic code is in place, 325 we will macro-ize everything and add PS_TYPE_UINT16 and PS_TYPE_DOUBLE. 326 327 *****************************************************************************/ 328 psStats *psArrayStats(const psVector *restrict myVector, 329 const psVector *restrict maskVector, 323 330 unsigned int maskVal, 324 331 psStats *stats) … … 328 335 newStruct = psStatsAlloc(stats->options); 329 336 if (myVector == NULL) { 330 ps Error(__func__,337 psAbort(__func__, 331 338 "Input data array (myVector) was NULL."); 332 339 } 333 340 334 if ((maskVector != NULL) && 335 (myVector->n != maskVector->n)) { 336 psError(__func__, "Vector data and vector mask are of different sizes."); 341 if (myVector->type.type != PS_TYPE_FLOAT) { 342 psAbort(__func__, 343 "Only data type PS_TYPE_FLOAT is currently supported."); 344 } 345 346 if (maskVector != NULL) { 347 if (myVector->n != maskVector->n) { 348 psAbort(__func__, 349 "Vector data and vector mask are of different sizes."); 350 } 351 if (maskVector->type.type != PS_TYPE_UINT8) { 352 psAbort(__func__, 353 "Vector mask must be type PS_TYPE_UINT8"); 354 } 337 355 } 338 356 … … 426 444 // OLD CODE: Should we check for an unknown option? 427 445 // default: 428 // ps Error(__func__, "Unknown options 0x%x.\n", stats->options);446 // psAbort(__func__, "Unknown options 0x%x.\n", stats->options); 429 447 430 448 return(newStruct);
Note:
See TracChangeset
for help on using the changeset viewer.
