Changeset 1385 for trunk/psLib/src/collections
- Timestamp:
- Aug 4, 2004, 1:37:39 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 9 edited
-
psArray.c (modified) (2 diffs)
-
psBitSet.c (modified) (3 diffs)
-
psList.c (modified) (3 diffs)
-
psMetadata.c (modified) (18 diffs)
-
psMetadata.h (modified) (3 diffs)
-
psScalar.c (modified) (1 diff)
-
psScalar.h (modified) (1 diff)
-
psVector.c (modified) (8 diffs)
-
psVector.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.c
r1228 r1385 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-0 7-15 22:18:02$10 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-08-04 23:37:39 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 67 67 psError(__func__, "Null input vector\n"); 68 68 return NULL; 69 } else if(in->nalloc != nalloc) { // No need to realloc to same size 70 if(nalloc < in->n) { 71 for (int i = nalloc; i < in->n; i++) { // For reduction in vector size 72 psFree(in->data[i]); 69 } else 70 if(in->nalloc != nalloc) { // No need to realloc to same size 71 if(nalloc < in->n) { 72 for (int i = nalloc; i < in->n; i++) { // For reduction in vector size 73 psFree(in->data[i]); 74 } 75 in->n = nalloc; 73 76 } 74 in->n = nalloc; 77 78 // Realloc after decrementation to avoid accessing freed array elements 79 in->data = psRealloc(in->data,nalloc*sizeof(psPTR)); 80 in->nalloc = nalloc; 75 81 } 76 77 // Realloc after decrementation to avoid accessing freed array elements78 in->data = psRealloc(in->data,nalloc*sizeof(psPTR));79 in->nalloc = nalloc;80 }81 82 82 83 return in; -
trunk/psLib/src/collections/psBitSet.c
r1172 r1385 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 7-01 21:48:11$12 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-04 23:37:39 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 126 126 psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__); 127 127 return inBitSet; 128 } else if(bit < 0) { 129 psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit); 130 return inBitSet; 131 } else if(bit > inBitSet->n*8-1) { 132 psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit); 133 return inBitSet; 134 } 128 } else 129 if(bit < 0) { 130 psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit); 131 return inBitSet; 132 } else 133 if(bit > inBitSet->n*8-1) { 134 psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit); 135 return inBitSet; 136 } 135 137 136 138 // Variable byte is the byte in the array that contains the bit to be set … … 148 150 psError(__func__, " : Line %d - Null psBitSet for inBitSet argument", __LINE__); 149 151 return 0; 150 } else if(bit < 0) { 151 psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit); 152 return 0; 153 } else if(bit > inBitSet->n*8-1) { 154 psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit); 155 return 0; 156 } 152 } else 153 if(bit < 0) { 154 psError(__func__, " : Line %d - Bit position too small: %d", __LINE__, bit); 155 return 0; 156 } else 157 if(bit > inBitSet->n*8-1) { 158 psError(__func__, " : Line %d - Bit position too large: %d", __LINE__, bit); 159 return 0; 160 } 157 161 158 162 // Variable byte is the byte in the array that contains the bit to be tested -
trunk/psLib/src/collections/psList.c
r1228 r1385 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 7-15 22:18:02$8 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-08-04 23:37:39 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 349 349 if (list->iter == ITER_INIT_HEAD) { 350 350 return list->head; 351 } else if (list->iter == ITER_INIT_TAIL) { 352 return list->tail; 353 } else { 354 return list->iter; 355 } 351 } else 352 if (list->iter == ITER_INIT_TAIL) { 353 return list->tail; 354 } else { 355 return list->iter; 356 } 356 357 } 357 358 … … 360 361 if (list->iter == ITER_INIT_HEAD) { 361 362 return 0; 362 } else if (list->iter == ITER_INIT_TAIL) { 363 return list->size-1; 364 } else { 365 return list->iterIndex; 366 } 363 } else 364 if (list->iter == ITER_INIT_TAIL) { 365 return list->size-1; 366 } else { 367 return list->iterIndex; 368 } 367 369 } 368 370 -
trunk/psLib/src/collections/psMetadata.c
r1381 r1385 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-08-04 2 1:05:24$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-08-04 23:37:39 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 65 65 { 66 66 psMetadataType type; 67 67 68 68 type = metadataItem->type; 69 69 70 70 if ( metadataItem == NULL ) { 71 return ;72 }73 71 return ; 72 } 73 74 74 psFree( metadataItem->name ); 75 75 psFree( metadataItem->comment ); 76 76 psFree( metadataItem->items ); 77 77 78 78 if ( type == PS_META_STR || 79 79 type == PS_META_IMG || … … 82 82 type == PS_META_ASTROM || 83 83 type == PS_META_UNKNOWN ) { 84 psFree( metadataItem->data.V );85 }84 psFree( metadataItem->data.V ); 85 } 86 86 } 87 87 … … 89 89 { 90 90 if ( metadata == NULL ) { 91 return ;92 }91 return ; 92 } 93 93 psFree( metadata->list ); 94 94 psFree( metadata->table ); … … 103 103 va_list argPtr; 104 104 psMetadataItem *metadataItem = NULL; 105 105 106 106 // Get the variable list parameters to pass to allocation function 107 107 va_start( argPtr, comment ); 108 108 109 109 // Call metadata item allocation 110 110 metadataItem = psMetadataItemAllocV( name, type, comment, argPtr ); 111 111 112 112 // Clean up stack after variable arguement has been used 113 113 va_end( argPtr ); 114 114 115 115 return metadataItem; 116 116 } … … 119 119 { 120 120 psMetadataItem * metadataItem = NULL; 121 121 122 122 if ( name == NULL ) { 123 psError( __func__, "Null value for string not allowed" );124 return NULL;125 }126 123 psError( __func__, "Null value for string not allowed" ); 124 return NULL; 125 } 126 127 127 // Allocate metadata item 128 128 metadataItem = ( psMetadataItem * ) psAlloc( sizeof( psMetadataItem ) ); 129 129 if ( metadataItem == NULL ) { 130 psAbort( __func__, "Failed to allocate memory" );131 }132 130 psAbort( __func__, "Failed to allocate memory" ); 131 } 132 133 133 // Set deallocator 134 134 p_psMemSetDeallocator( metadataItem, ( psFreeFcn ) metadataItemFree ); 135 135 136 136 // Allocate and set metadata item comment 137 137 metadataItem->comment = ( char * ) psAlloc( sizeof( char ) * MAX_STRING_LENGTH ); 138 138 if ( comment == NULL ) { 139 // Per SDRS, null isn't allowed, must use "" instead140 strncpy( metadataItem->comment, "", MAX_STRING_LENGTH );141 } else {142 strncpy( metadataItem->comment, comment, MAX_STRING_LENGTH );143 }144 139 // Per SDRS, null isn't allowed, must use "" instead 140 strncpy( metadataItem->comment, "", MAX_STRING_LENGTH ); 141 } else { 142 strncpy( metadataItem->comment, comment, MAX_STRING_LENGTH ); 143 } 144 145 145 // Set metadata item unique id 146 146 *( int* ) ( &metadataItem->id ) = ++metadataId; 147 147 148 148 // Set metadata item type 149 149 metadataItem->type = type; 150 150 151 151 // Set metadata item value 152 152 switch ( type ) { 153 case PS_META_BOOL:154 metadataItem->data.B = ( bool ) va_arg( argPtr, int );155 break;156 case PS_META_S32:157 metadataItem->data.S32 = va_arg( argPtr, psS32 );158 break;159 case PS_META_F32:160 metadataItem->data.F32 = ( psF32 ) va_arg( argPtr, psF64 );161 break;162 case PS_META_F64:163 metadataItem->data.F64 = va_arg( argPtr, psF64 );164 break;165 case PS_META_STR:166 metadataItem->data.V = psStringNCopy( va_arg( argPtr, char* ), MAX_STRING_LENGTH );167 break;168 case PS_META_IMG:169 case PS_META_JPEG:170 case PS_META_PNG:171 case PS_META_ASTROM:172 case PS_META_UNKNOWN:173 default:174 psError( __func__, "Invalid psMetadataType: %d", type );175 }176 153 case PS_META_BOOL: 154 metadataItem->data.B = ( bool ) va_arg( argPtr, int ); 155 break; 156 case PS_META_S32: 157 metadataItem->data.S32 = va_arg( argPtr, psS32 ); 158 break; 159 case PS_META_F32: 160 metadataItem->data.F32 = ( psF32 ) va_arg( argPtr, psF64 ); 161 break; 162 case PS_META_F64: 163 metadataItem->data.F64 = va_arg( argPtr, psF64 ); 164 break; 165 case PS_META_STR: 166 metadataItem->data.V = psStringNCopy( va_arg( argPtr, char* ), MAX_STRING_LENGTH ); 167 break; 168 case PS_META_IMG: 169 case PS_META_JPEG: 170 case PS_META_PNG: 171 case PS_META_ASTROM: 172 case PS_META_UNKNOWN: 173 default: 174 psError( __func__, "Invalid psMetadataType: %d", type ); 175 } 176 177 177 // Allocate and set metadata item name 178 178 metadataItem->name = ( char * ) psAlloc( sizeof( char ) * MAX_STRING_LENGTH ); 179 179 vsprintf( metadataItem->name, name, argPtr ); 180 180 181 181 // Allocate metadata items with same name. 182 182 metadataItem->items = psListAlloc( NULL ); 183 183 184 184 return metadataItem; 185 185 } … … 190 190 psHash *table = NULL; 191 191 psMetadata *metadata = NULL; 192 192 193 193 // Allocate metadata 194 194 metadata = ( psMetadata * ) psAlloc( sizeof( psMetadata ) ); 195 195 if ( metadata == NULL ) { 196 psAbort( __func__, "Failed to allocate metadata" );197 }198 196 psAbort( __func__, "Failed to allocate metadata" ); 197 } 198 199 199 // Set deallocator 200 200 p_psMemSetDeallocator( metadata, ( psFreeFcn ) metadataFree ); 201 201 202 202 // Allocate metadata's internal containers 203 203 list = ( psList * ) psListAlloc( NULL ); 204 204 if ( list == NULL ) { 205 psAbort( __func__, "Failed to allocate list" );206 }207 205 psAbort( __func__, "Failed to allocate list" ); 206 } 207 208 208 table = ( psHash * ) psHashAlloc( 10 ); 209 209 if ( table == NULL ) { 210 psAbort( __func__, "Failed to allocate table" );211 }212 210 psAbort( __func__, "Failed to allocate table" ); 211 } 212 213 213 metadata->list = list; 214 214 metadata->table = table; 215 215 216 216 return metadata; 217 217 } … … 224 224 psMetadataItem *value = NULL; 225 225 psMetadataType type = PS_META_ITEM_SET; 226 226 227 227 if ( md == NULL ) { 228 psError( __func__, "Null metadata collection not allowed" );229 return false;230 }231 228 psError( __func__, "Null metadata collection not allowed" ); 229 return false; 230 } 231 232 232 if ( metadataItem == NULL ) { 233 psError( __func__, "Null metadata item not allowed" );234 return false;235 }236 233 psError( __func__, "Null metadata item not allowed" ); 234 return false; 235 } 236 237 237 type = metadataItem->type; 238 238 239 239 mdTable = md->table; 240 240 if ( mdTable == NULL ) { 241 psError( __func__, "Null metadata table not allowed" );242 return false;243 }244 245 mdList = md->list; 246 if ( mdList == NULL ) { 247 psError( __func__, "Null metadata list not allowed" );248 return false;249 }250 241 psError( __func__, "Null metadata table not allowed" ); 242 return false; 243 } 244 245 mdList = md->list; 246 if ( mdList == NULL ) { 247 psError( __func__, "Null metadata list not allowed" ); 248 return false; 249 } 250 251 251 key = metadataItem->name; 252 252 if ( key == NULL ) { 253 psError( __func__, "Null key item not allowed" );254 return false;255 }256 253 psError( __func__, "Null key item not allowed" ); 254 return false; 255 } 256 257 257 // Check if key is already in table 258 258 value = ( psMetadataItem* ) psHashLookup( mdTable, key ); 259 259 if ( value != NULL && type != PS_META_ITEM_SET ) { 260 261 // The key was found and the new metadata item is a leaf node (its type isn't PS_META_ITEM_SET), so 262 // add the new metadata item to hash as a child of the existing metadata item folder node. 263 if ( !psListAdd( value->items, metadataItem, where ) ) { 264 psError( __func__, "Couldn't add metadata item to items list. Name: %s", 265 metadataItem->name ); 266 return false; 267 } 268 } else if ( value != NULL ) { 269 260 261 // The key was found and the new metadata item is a leaf node (its type isn't PS_META_ITEM_SET), so 262 // add the new metadata item to hash as a child of the existing metadata item folder node. 263 if ( !psListAdd( value->items, metadataItem, where ) ) { 264 psError( __func__, "Couldn't add metadata item to items list. Name: %s", 265 metadataItem->name ); 266 return false; 267 } 268 } else 269 if ( value != NULL ) { 270 270 271 // The key was found and the new metadata item is a folder node. Don't add new metadata item, since 271 272 // it will wipe out existing node. … … 274 275 return false; 275 276 } else { 276 277 277 278 // Duplicate key not found. Add new metadata item to metadata collection's hash 278 279 if ( !psHashAdd( mdTable, key, metadataItem ) ) { 279 psError( __func__, "Couldn't add metadata item to metadata collection table. Name: %s",280 metadataItem->name );281 return false;282 }283 } 284 280 psError( __func__, "Couldn't add metadata item to metadata collection table. Name: %s", 281 metadataItem->name ); 282 return false; 283 } 284 } 285 285 286 // Add all items to metadata collection's list, even if they have the same metadata item names 286 287 if ( !psListAdd( md->list, metadataItem, where ) ) { 287 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",288 metadataItem->name );289 return false;290 }291 288 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s", 289 metadataItem->name ); 290 return false; 291 } 292 292 293 return true; 293 294 } … … 298 299 va_list argPtr; 299 300 psMetadataItem *metadataItem = NULL; 300 301 301 302 va_start( argPtr, comment ); 302 303 metadataItem = psMetadataItemAllocV( name, type, comment, argPtr ); 303 304 va_end( argPtr ); 304 305 305 306 if ( !psMetadataAddItem( md, where, metadataItem ) ) { 306 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",307 metadataItem->name );308 psFree( metadataItem );309 return false;310 }311 307 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s", 308 metadataItem->name ); 309 psFree( metadataItem ); 310 return false; 311 } 312 312 313 // Decrement reference count, since the metadata item is now in metadata collection and no longer needed here 313 314 psMemDecrRefCounter( metadataItem ); 314 315 315 316 return true; 316 317 } … … 323 324 psMetadataItem *entry = NULL; 324 325 psMetadataItem *entryChild = NULL; 325 326 mdList = md->list; 327 if ( mdList == NULL ) { 328 psError( __func__, "Null metadata list not allowed" );329 return false;330 }331 326 327 mdList = md->list; 328 if ( mdList == NULL ) { 329 psError( __func__, "Null metadata list not allowed" ); 330 return false; 331 } 332 332 333 mdTable = md->table; 333 334 if ( mdTable == NULL ) { 334 psError( __func__, "Null metadata table not allowed" );335 return false;336 }337 335 psError( __func__, "Null metadata table not allowed" ); 336 return false; 337 } 338 338 339 // Select removal by key or index 339 340 if ( key != NULL ) { 340 341 // Remove by key name 342 entry = ( psMetadataItem* ) psHashLookup( mdTable, key ); 343 if ( entry == NULL ) { 344 psError( __func__, "Couldn't find metadata item remove. Name: %s", key ); 345 return false; 346 } 347 348 numChildren = entry->items->size; 349 if ( entry->type == PS_META_ITEM_SET && numChildren > 0 ) { 350 351 // Table entry has children. Entry and children must be removed from metadata collection's list 352 psListSetIterator( mdList, PS_LIST_HEAD ); 353 entryChild = psListGetCurrent( mdList ); 354 while ( entryChild != NULL ) { 355 if ( !psListRemove( entry->items, entryChild, PS_LIST_UNKNOWN ) ) { 356 psError( __func__, "Couldn't remove metadata item from list. Name: %s", key ); 357 return false; 358 } 359 entryChild = psListGetNext( entry->items ); 360 } 361 } 362 363 // Remove entry from metadata collection's list 364 if ( !psListRemove( mdList, entry, PS_LIST_UNKNOWN ) ) { 341 342 // Remove by key name 343 entry = ( psMetadataItem* ) psHashLookup( mdTable, key ); 344 if ( entry == NULL ) { 345 psError( __func__, "Couldn't find metadata item remove. Name: %s", key ); 346 return false; 347 } 348 349 numChildren = entry->items->size; 350 if ( entry->type == PS_META_ITEM_SET && numChildren > 0 ) { 351 352 // Table entry has children. Entry and children must be removed from metadata collection's list 353 psListSetIterator( mdList, PS_LIST_HEAD ); 354 entryChild = psListGetCurrent( mdList ); 355 while ( entryChild != NULL ) { 356 if ( !psListRemove( entry->items, entryChild, PS_LIST_UNKNOWN ) ) { 365 357 psError( __func__, "Couldn't remove metadata item from list. Name: %s", key ); 366 358 return false; 367 359 } 368 369 // Remove entry from metadata collection's table 370 if ( !psHashRemove( mdTable, key ) ) { 371 psError( __func__, "Couldn't remove metadata item from table. Name: %s", key ); 372 return false; 373 } 374 } else { 375 376 // Remove by index 377 entry = psListGet( mdList, where ); 378 if ( entry == NULL ) { 379 psError( __func__, "Couldn't find metadata item from list. Index: %d", where ); 380 return false; 381 } 382 383 key = entry->name; 384 if ( key == NULL ) { 385 psError( __func__, "Null key name not allowed. Index: %d", where ); 386 return false; 387 } 388 389 // Use recursive remove, now that key is known 390 psMetadataRemove( md, PS_LIST_UNKNOWN, key ); 391 } 392 360 entryChild = psListGetNext( entry->items ); 361 } 362 } 363 364 // Remove entry from metadata collection's list 365 if ( !psListRemove( mdList, entry, PS_LIST_UNKNOWN ) ) { 366 psError( __func__, "Couldn't remove metadata item from list. Name: %s", key ); 367 return false; 368 } 369 370 // Remove entry from metadata collection's table 371 if ( !psHashRemove( mdTable, key ) ) { 372 psError( __func__, "Couldn't remove metadata item from table. Name: %s", key ); 373 return false; 374 } 375 } else { 376 377 // Remove by index 378 entry = psListGet( mdList, where ); 379 if ( entry == NULL ) { 380 psError( __func__, "Couldn't find metadata item from list. Index: %d", where ); 381 return false; 382 } 383 384 key = entry->name; 385 if ( key == NULL ) { 386 psError( __func__, "Null key name not allowed. Index: %d", where ); 387 return false; 388 } 389 390 // Use recursive remove, now that key is known 391 psMetadataRemove( md, PS_LIST_UNKNOWN, key ); 392 } 393 393 394 return true; 394 395 } … … 398 399 psHash * mdTable = NULL; 399 400 psMetadataItem *entry = NULL; 400 401 401 402 mdTable = md->table; 402 403 if ( mdTable == NULL ) { 403 psError( __func__, "Null metadata table not allowed" );404 return NULL;405 }406 404 psError( __func__, "Null metadata table not allowed" ); 405 return NULL; 406 } 407 407 408 if ( key == NULL ) { 408 psError( __func__, "Null key name not allowed" );409 return NULL;410 }411 409 psError( __func__, "Null key name not allowed" ); 410 return NULL; 411 } 412 412 413 entry = ( psMetadataItem* ) psHashLookup( mdTable, key ); 413 414 if ( entry == NULL ) { 414 psError( __func__, "Could not find metadata item with given key. Key: %s", key );415 return NULL;416 }417 415 psError( __func__, "Could not find metadata item with given key. Key: %s", key ); 416 return NULL; 417 } 418 418 419 return entry; 419 420 } … … 423 424 psList * mdList = NULL; 424 425 psMetadataItem *entry = NULL; 425 426 mdList = md->list; 427 if ( mdList == NULL ) { 428 psError( __func__, "Null metadata list not allowed" );429 return NULL;430 }431 426 427 mdList = md->list; 428 if ( mdList == NULL ) { 429 psError( __func__, "Null metadata list not allowed" ); 430 return NULL; 431 } 432 432 433 entry = ( psMetadataItem* ) psListGet( mdList, where ); 433 434 if ( entry == NULL ) { 434 psError( __func__, "Couldn't find metadata item with given index. Index: %d", where );435 return NULL;436 }437 435 psError( __func__, "Couldn't find metadata item with given index. Index: %d", where ); 436 return NULL; 437 } 438 438 439 return entry; 439 440 } … … 442 443 { 443 444 psList * mdList = NULL; 444 445 mdList = md->list; 446 if ( mdList == NULL ) { 447 psError( __func__, "Null metadata list not allowed" );448 return false;449 }450 445 446 mdList = md->list; 447 if ( mdList == NULL ) { 448 psError( __func__, "Null metadata list not allowed" ); 449 return false; 450 } 451 451 452 psListSetIterator( mdList, where ); 452 453 453 454 return true; 454 455 } … … 458 459 psList * mdList = NULL; 459 460 psMetadataItem *entry = NULL; 460 461 mdList = md->list; 462 if ( mdList == NULL ) { 463 psError( __func__, "Null metadata list not allowed" );464 return NULL;465 }466 467 mdList = md->list; 468 if ( mdList == NULL ) { 469 psError( __func__, "Null metadata list not allowed" );470 return NULL;471 }472 461 462 mdList = md->list; 463 if ( mdList == NULL ) { 464 psError( __func__, "Null metadata list not allowed" ); 465 return NULL; 466 } 467 468 mdList = md->list; 469 if ( mdList == NULL ) { 470 psError( __func__, "Null metadata list not allowed" ); 471 return NULL; 472 } 473 473 474 psListSetIterator( mdList, which ); 474 475 entry = psListGetCurrent( mdList ); 475 476 while ( entry != NULL ) { 476 if ( !strncmp( match, entry->name, strlen( match ) ) ) {477 478 // Match found479 return entry;480 }481 entry = psListGetNext( mdList );482 }483 477 if ( !strncmp( match, entry->name, strlen( match ) ) ) { 478 479 // Match found 480 return entry; 481 } 482 entry = psListGetNext( mdList ); 483 } 484 484 485 // Match not found 485 486 if ( entry == NULL ) { 486 psError( __func__, "Couldn't find metadata item with given match. Match: %s", match );487 }488 487 psError( __func__, "Couldn't find metadata item with given match. Match: %s", match ); 488 } 489 489 490 return entry; 490 491 } … … 494 495 psList * mdList = NULL; 495 496 psMetadataItem *entry = NULL; 496 497 mdList = md->list; 498 if ( mdList == NULL ) { 499 psError( __func__, "Null metadata list not allowed" );500 return NULL;501 }502 503 mdList = md->list; 504 if ( mdList == NULL ) { 505 psError( __func__, "Null metadata list not allowed" );506 return NULL;507 }508 497 498 mdList = md->list; 499 if ( mdList == NULL ) { 500 psError( __func__, "Null metadata list not allowed" ); 501 return NULL; 502 } 503 504 mdList = md->list; 505 if ( mdList == NULL ) { 506 psError( __func__, "Null metadata list not allowed" ); 507 return NULL; 508 } 509 509 510 psListSetIterator( mdList, which ); 510 511 entry = psListGetCurrent( mdList ); 511 512 while ( entry != NULL ) { 512 if ( !strncmp( match, entry->name, strlen( match ) ) ) {513 514 // Match found515 return entry;516 }517 entry = psListGetPrevious( mdList );518 }519 513 if ( !strncmp( match, entry->name, strlen( match ) ) ) { 514 515 // Match found 516 return entry; 517 } 518 entry = psListGetPrevious( mdList ); 519 } 520 520 521 // Match not found 521 522 if ( entry == NULL ) { 522 psError( __func__, "Couldn't find metadata item with given match. Match: %s", match );523 }524 523 psError( __func__, "Couldn't find metadata item with given match. Match: %s", match ); 524 } 525 525 526 return entry; 526 527 } … … 529 530 { 530 531 psMetadataType type; 531 532 532 533 if ( fd == NULL ) { 533 psError( __func__, "Null file descriptor not allowed" );534 return ;535 }536 534 psError( __func__, "Null file descriptor not allowed" ); 535 return ; 536 } 537 537 538 if ( format == NULL ) { 538 psError( __func__, "Null format not allowed" );539 return ;540 }541 539 psError( __func__, "Null format not allowed" ); 540 return ; 541 } 542 542 543 if ( metadataItem == NULL ) { 543 psError( __func__, "Null metadata not allowed" );544 return ;545 }546 544 psError( __func__, "Null metadata not allowed" ); 545 return ; 546 } 547 547 548 type = metadataItem->type; 548 549 549 550 switch ( type ) { 550 case PS_META_BOOL:551 fprintf( fd, format, metadataItem->data.B );552 break;553 case PS_META_S32:554 fprintf( fd, format, metadataItem->data.S32 );555 break;556 case PS_META_F32:557 fprintf( fd, format, metadataItem->data.F32 );558 break;559 case PS_META_F64:560 fprintf( fd, format, metadataItem->data.F64 );561 break;562 case PS_META_STR:563 fprintf( fd, format, metadataItem->data.V );564 break;565 case PS_META_ITEM_SET:566 case PS_META_IMG:567 case PS_META_JPEG:568 case PS_META_PNG:569 case PS_META_ASTROM:570 case PS_META_UNKNOWN:571 default:572 psError( __func__, " Invalid psMetadataType to print: %d", type );573 }551 case PS_META_BOOL: 552 fprintf( fd, format, metadataItem->data.B ); 553 break; 554 case PS_META_S32: 555 fprintf( fd, format, metadataItem->data.S32 ); 556 break; 557 case PS_META_F32: 558 fprintf( fd, format, metadataItem->data.F32 ); 559 break; 560 case PS_META_F64: 561 fprintf( fd, format, metadataItem->data.F64 ); 562 break; 563 case PS_META_STR: 564 fprintf( fd, format, metadataItem->data.V ); 565 break; 566 case PS_META_ITEM_SET: 567 case PS_META_IMG: 568 case PS_META_JPEG: 569 case PS_META_PNG: 570 case PS_META_ASTROM: 571 case PS_META_UNKNOWN: 572 default: 573 psError( __func__, " Invalid psMetadataType to print: %d", type ); 574 } 574 575 } 575 576 … … 590 591 int keyNum = 0; 591 592 psMetadataType metadataItemType; 592 593 593 594 if ( fd == NULL ) { 594 psError( __func__, "Null FITS file descriptor not allowed" );595 return NULL;596 }597 595 psError( __func__, "Null FITS file descriptor not allowed" ); 596 return NULL; 597 } 598 598 599 if ( extname == NULL && extnum == 0 ) { 599 psError( __func__, "Null extname AND extnum = 0 not allowed" ); 600 return NULL; 601 } else if ( extname && extnum ) { 600 psError( __func__, "Null extname AND extnum = 0 not allowed" ); 601 return NULL; 602 } else 603 if ( extname && extnum ) { 602 604 psError( __func__, "Both extname AND extnum arguments should not have values." ); 603 605 return NULL; 604 606 } 605 607 606 608 // Allocate metadata if user didn't 607 609 if ( output == NULL ) { 608 output = psMetadataAlloc();609 }610 610 output = psMetadataAlloc(); 611 } 612 611 613 // Move to user designated HDU number or HDU name in FITS file. HDU numbers starts at one. 612 614 if ( extname == NULL ) { 613 if ( fits_movabs_hdu( fd, extnum, &hduType, &status ) != 0 ) { 614 fits_get_errstatus( status, fitsErr ); 615 psError( __func__, "FITS error while locating header: %s", fitsErr ); 616 status = 0; 617 return output; 618 } 619 } else if ( extnum > 0 ) { 615 if ( fits_movabs_hdu( fd, extnum, &hduType, &status ) != 0 ) { 616 fits_get_errstatus( status, fitsErr ); 617 psError( __func__, "FITS error while locating header: %s", fitsErr ); 618 status = 0; 619 return output; 620 } 621 } else 622 if ( extnum > 0 ) { 620 623 tempExtname = ( char* ) extname; 621 624 if ( fits_movnam_hdu( fd, ANY_HDU, tempExtname, 0, &status ) != 0 ) { 622 fits_get_errstatus( status, fitsErr );623 psError( __func__, "FITS error while locating header: %s", fitsErr );624 status = 0;625 return output;626 }627 } 628 625 fits_get_errstatus( status, fitsErr ); 626 psError( __func__, "FITS error while locating header: %s", fitsErr ); 627 status = 0; 628 return output; 629 } 630 } 631 629 632 // Get number of key names 630 633 if ( fits_get_hdrpos( fd, &numKeys, &keyNum, &status ) != 0 ) { 634 fits_get_errstatus( status, fitsErr ); 635 psError( __func__, "FITS error while reading keys: %s", fitsErr ); 636 status = 0; 637 return output; 638 } 639 640 // Get each key name. Keywords start at one. 641 for ( i = 1; i <= numKeys; i++ ) { 642 if ( fits_read_keyn( fd, i, keyName, keyValue, keyComment, &status ) != 0 ) { 631 643 fits_get_errstatus( status, fitsErr ); 632 psError( __func__, "FITS error while reading key s: %s", fitsErr );644 psError( __func__, "FITS error while reading key number %d: %s", i, fitsErr ); 633 645 status = 0; 634 646 return output; 635 647 } 636 637 // Get each key name. Keywords start at one. 638 for ( i = 1; i <= numKeys; i++ ) { 639 if ( fits_read_keyn( fd, i, keyName, keyValue, keyComment, &status ) != 0 ) { 640 fits_get_errstatus( status, fitsErr ); 641 psError( __func__, "FITS error while reading key number %d: %s", i, fitsErr ); 642 status = 0; 643 return output; 644 } 645 if ( fits_get_keytype( keyValue, &keyType, &status ) != 0 ) { 646 fits_get_errstatus( status, fitsErr ); 647 if ( status != VALUE_UNDEFINED ) { 648 psError( __func__, "FITS error while determining key type: %s", fitsErr ); 649 status = 0; 650 return output; 651 } else { 652 // Some keywords are still valid even though they don't have a type or value, like COMMENTS 653 keyType = 'C'; 654 status = 0; 655 } 656 } 657 658 switch ( keyType ) { 659 case 'I': 660 metadataItemType = PS_META_S32; 661 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, atoi( keyValue ) ); 662 break; 663 case 'F': 664 metadataItemType = PS_META_F64; 665 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, atof( keyValue ) ); 666 break; 667 case 'C': 668 metadataItemType = PS_META_STR; 669 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, keyValue ); 670 break; 671 case 'L': 672 metadataItemType = PS_META_BOOL; 673 tempBool = ( keyValue[ 0 ] == 'T' ) ? 1 : 0; 674 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, tempBool ); 675 break; 676 case 'U': 677 case 'X': 678 default: 679 psError( __func__, "Invalid psMetadataType: %c", keyType ); 680 return output; 681 } 682 683 if ( !success ) { 684 psError( __func__, "Failed to add metadata item. Name: %s", keyName ); 685 } 686 } 687 648 if ( fits_get_keytype( keyValue, &keyType, &status ) != 0 ) { 649 fits_get_errstatus( status, fitsErr ); 650 if ( status != VALUE_UNDEFINED ) { 651 psError( __func__, "FITS error while determining key type: %s", fitsErr ); 652 status = 0; 653 return output; 654 } else { 655 // Some keywords are still valid even though they don't have a type or value, like COMMENTS 656 keyType = 'C'; 657 status = 0; 658 } 659 } 660 661 switch ( keyType ) { 662 case 'I': 663 metadataItemType = PS_META_S32; 664 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, atoi( keyValue ) ); 665 break; 666 case 'F': 667 metadataItemType = PS_META_F64; 668 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, atof( keyValue ) ); 669 break; 670 case 'C': 671 metadataItemType = PS_META_STR; 672 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, keyValue ); 673 break; 674 case 'L': 675 metadataItemType = PS_META_BOOL; 676 tempBool = ( keyValue[ 0 ] == 'T' ) ? 1 : 0; 677 success = psMetadataAdd( output, PS_LIST_HEAD, keyName, metadataItemType, keyComment, tempBool ); 678 break; 679 case 'U': 680 case 'X': 681 default: 682 psError( __func__, "Invalid psMetadataType: %c", keyType ); 683 return output; 684 } 685 686 if ( !success ) { 687 psError( __func__, "Failed to add metadata item. Name: %s", keyName ); 688 } 689 } 690 688 691 return output; 689 692 } -
trunk/psLib/src/collections/psMetadata.h
r1382 r1385 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-04 2 2:11:09 $12 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-04 23:37:39 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 */ 60 60 typedef struct psMetadataItem 61 { 62 const int id; ///< Unique ID for metadata item. 63 char *restrict name; ///< Name of metadata item. 64 psMetadataType type; ///< Type of metadata item. 65 union 61 66 { 62 const int id; ///< Unique ID for metadata item. 63 char *restrict name; ///< Name of metadata item. 64 psMetadataType type; ///< Type of metadata item. 65 union 66 { 67 bool B; 68 psS32 S32; ///< Signed 32-bit integer data. 69 psF32 F32; ///< Single-precision float data. 70 psF64 F64; ///< Double-precision float data. 71 psPTR V; ///< Pointer to other type of data. 72 }data; ///< Union for data types. 73 char *comment; ///< Optional comment ("", not NULL). 74 psList *restrict items; ///< List of psMetadataItems with same name. 75 } 67 bool B; 68 psS32 S32; ///< Signed 32-bit integer data. 69 psF32 F32; ///< Single-precision float data. 70 psF64 F64; ///< Double-precision float data. 71 psPTR V; ///< Pointer to other type of data. 72 }data; ///< Union for data types. 73 char *comment; ///< Optional comment ("", not NULL). 74 psList *restrict items; ///< List of psMetadataItems with same name. 75 } 76 76 psMetadataItem; 77 77 … … 83 83 */ 84 84 typedef struct psMetadata 85 {86 psList* restrict list;87 psHash* restrict table;88 }85 { 86 psList* restrict list; 87 psHash* restrict table; 88 } 89 89 psMetadata; 90 90 -
trunk/psLib/src/collections/psScalar.c
r1162 r1385 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-0 7-01 00:14:40$10 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-08-04 23:37:39 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/src/collections/psScalar.h
r1060 r1385 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 6-18 23:36:02$12 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-04 23:37:39 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/src/collections/psVector.c
r1360 r1385 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-0 7-31 02:28:10$10 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-08-04 23:37:39 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 63 63 psVector * psVec = NULL; 64 64 int elementSize = 0; 65 65 66 66 // Invalid nalloc 67 67 if ( nalloc < 1 ) { 68 psError( __func__, "Invalid value for nalloc. nalloc: %d\n", nalloc );69 return NULL;70 }71 68 psError( __func__, "Invalid value for nalloc. nalloc: %d\n", nalloc ); 69 return NULL; 70 } 71 72 72 elementSize = PSELEMTYPE_SIZEOF( elemType ); 73 73 74 74 // Create vector struct 75 75 psVec = ( psVector * ) psAlloc( sizeof( psVector ) ); 76 76 p_psMemSetDeallocator( psVec, ( psFreeFcn ) vectorFree ); 77 77 78 78 psVec->type.dimen = PS_DIMEN_VECTOR; 79 79 psVec->type.type = elemType; 80 80 psVec->nalloc = nalloc; 81 81 psVec->n = nalloc; 82 82 83 83 // Create vector data array 84 84 psVec->data.V = psAlloc( nalloc * elementSize ); 85 85 86 86 return psVec; 87 87 } … … 91 91 int elementSize = 0; 92 92 psElemType elemType; 93 93 94 94 // Invalid nalloc 95 95 if ( nalloc < 1 ) { 96 psError( __func__, "Invalid value for realloc (%d)\n", nalloc );97 return NULL;98 }99 96 psError( __func__, "Invalid value for realloc (%d)\n", nalloc ); 97 return NULL; 98 } 99 100 100 if ( in == NULL ) { 101 psError( __func__, "Null input vector\n" ); 102 return NULL; 103 } else if ( in->nalloc != nalloc ) { // No need to realloc to same size 101 psError( __func__, "Null input vector\n" ); 102 return NULL; 103 } else 104 if ( in->nalloc != nalloc ) { // No need to realloc to same size 104 105 elemType = in->type.type; 105 106 elementSize = PSELEMTYPE_SIZEOF( elemType ); 106 107 if ( nalloc < in->n ) { 107 in->n = nalloc;108 }109 108 in->n = nalloc; 109 } 110 110 111 // Realloc after decrementation to avoid accessing freed array elements 111 112 in->data.V = psRealloc( in->data.V, nalloc * elementSize ); 112 113 in->nalloc = nalloc; 113 114 } 114 115 115 116 return in; 116 117 } … … 119 120 { 120 121 psElemType elemType; 121 122 122 123 if ( in == NULL ) { 123 return psVectorAlloc( nalloc, type );124 }125 124 return psVectorAlloc( nalloc, type ); 125 } 126 126 127 elemType = in->type.type; 127 128 128 129 if ( in->nalloc == nalloc && elemType == type ) { 129 // it is proper size/type already130 return in;131 }132 130 // it is proper size/type already 131 return in; 132 } 133 133 134 // Invalid nalloc 134 135 if ( nalloc < 1 ) { 135 psError( __func__, "Invalid value for nalloc (%d)\n", nalloc );136 psFree( in );137 return NULL;138 }139 140 136 psError( __func__, "Invalid value for nalloc (%d)\n", nalloc ); 137 psFree( in ); 138 return NULL; 139 } 140 141 141 142 in->data.V = psRealloc( in->data.V, nalloc * PSELEMTYPE_SIZEOF( type ) ); 142 143 143 144 in->type.type = type; 144 145 in->nalloc = nalloc; 145 146 in->n = nalloc; 146 147 147 148 return in; 148 149 } … … 156 157 void *outVec = NULL; 157 158 psElemType inType = 0; 158 159 159 160 if ( inVector == NULL ) { 160 psError( __func__, " : Line %d - Null input vector\n", __LINE__ );161 return outVector;162 }163 161 psError( __func__, " : Line %d - Null input vector\n", __LINE__ ); 162 return outVector; 163 } 164 164 165 inType = inVector->type.type; 165 166 inN = inVector->n; 166 167 inVec = inVector->data.V; 167 168 elSize = PSELEMTYPE_SIZEOF( inType ); 168 169 169 170 if ( outVector == NULL ) { 170 outVector = psVectorAlloc( inN, inType );171 outVector->n = inVector->n;172 }173 171 outVector = psVectorAlloc( inN, inType ); 172 outVector->n = inVector->n; 173 } 174 174 175 outN = outVector->n; 175 176 outVec = outVector->data.V; 176 177 177 178 if ( inN != outN ) { 178 psError( __func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n", __LINE__,179 inN, outN );180 return outVector;181 }182 179 psError( __func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n", __LINE__, 180 inN, outN ); 181 return outVector; 182 } 183 183 184 if ( inType != outVector->type.type ) { 184 psError( __func__, " : Line %d - Input and output vectors are not same type: in=%d out=%d\n", __LINE__,185 inType, outVector->type.type );186 return outVector;187 }188 185 psError( __func__, " : Line %d - Input and output vectors are not same type: in=%d out=%d\n", __LINE__, 186 inType, outVector->type.type ); 187 return outVector; 188 } 189 189 190 if ( inN == 0 ) { 190 psError( __func__, " : Line %d - No elements in use for input vector\n", __LINE__ );191 return outVector;192 }193 191 psError( __func__, " : Line %d - No elements in use for input vector\n", __LINE__ ); 192 return outVector; 193 } 194 194 195 if ( outN == 0 ) { 195 psError( __func__, " : Line %d - No elements in use for output vector\n", __LINE__ );196 return outVector;197 }198 196 psError( __func__, " : Line %d - No elements in use for output vector\n", __LINE__ ); 197 return outVector; 198 } 199 199 200 // Copy input vector values into output vector 200 201 memcpy( outVec, inVec, elSize * outN ); 201 202 202 203 // Sort output vector 203 204 switch ( inType ) { 204 case PS_TYPE_U8:205 qsort( outVec, inN, elSize, psCompareU8 );206 break;207 case PS_TYPE_U16:208 qsort( outVec, inN, elSize, psCompareU16 );209 break;210 case PS_TYPE_U32:211 qsort( outVec, inN, elSize, psCompareU32 );212 break;213 case PS_TYPE_U64:214 qsort( outVec, inN, elSize, psCompareU64 );215 break;216 case PS_TYPE_S8:217 qsort( outVec, inN, elSize, psCompareS8 );218 break;219 case PS_TYPE_S16:220 qsort( outVec, inN, elSize, psCompareS16 );221 break;222 case PS_TYPE_S32:223 qsort( outVec, inN, elSize, psCompareS32 );224 break;225 case PS_TYPE_S64:226 qsort( outVec, inN, elSize, psCompareS64 );227 break;228 case PS_TYPE_F32:229 qsort( outVec, inN, elSize, psCompareF32 );230 break;231 case PS_TYPE_F64:232 qsort( outVec, inN, elSize, psCompareF64 );233 break;234 default:235 psError( __func__, " : Line %d - Invalid psType\n", __LINE__ );236 }237 205 case PS_TYPE_U8: 206 qsort( outVec, inN, elSize, psCompareU8 ); 207 break; 208 case PS_TYPE_U16: 209 qsort( outVec, inN, elSize, psCompareU16 ); 210 break; 211 case PS_TYPE_U32: 212 qsort( outVec, inN, elSize, psCompareU32 ); 213 break; 214 case PS_TYPE_U64: 215 qsort( outVec, inN, elSize, psCompareU64 ); 216 break; 217 case PS_TYPE_S8: 218 qsort( outVec, inN, elSize, psCompareS8 ); 219 break; 220 case PS_TYPE_S16: 221 qsort( outVec, inN, elSize, psCompareS16 ); 222 break; 223 case PS_TYPE_S32: 224 qsort( outVec, inN, elSize, psCompareS32 ); 225 break; 226 case PS_TYPE_S64: 227 qsort( outVec, inN, elSize, psCompareS64 ); 228 break; 229 case PS_TYPE_F32: 230 qsort( outVec, inN, elSize, psCompareF32 ); 231 break; 232 case PS_TYPE_F64: 233 qsort( outVec, inN, elSize, psCompareF64 ); 234 break; 235 default: 236 psError( __func__, " : Line %d - Invalid psType\n", __LINE__ ); 237 } 238 238 239 return outVector; 239 240 } … … 241 242 #define SORT_INDICES(TYPE) \ 242 243 for(i=0; i<inN; i++) { \ 243 for(j=0; j<inN; j++) { \244 diff = fabs((double)tmpVector->data.TYPE[i] - inVec[j]); \245 if(diff < FLT_EPSILON) { \246 outVec[i] = j; \247 break; \248 } \249 } \250 }251 244 for(j=0; j<inN; j++) { \ 245 diff = fabs((double)tmpVector->data.TYPE[i] - inVec[j]); \ 246 if(diff < FLT_EPSILON) { \ 247 outVec[i] = j; \ 248 break; \ 249 } \ 250 } \ 251 } 252 252 253 psVector *psVectorSortIndex( psVector *restrict outVector, const psVector *restrict inVector ) 253 254 { … … 261 262 psVector *tmpVector = NULL; 262 263 psElemType inType = 0; 263 264 264 265 if ( inVector == NULL ) { 265 psError( __func__, " : Line %d - Null input vector\n", __LINE__ );266 return outVector;267 }268 266 psError( __func__, " : Line %d - Null input vector\n", __LINE__ ); 267 return outVector; 268 } 269 269 270 inN = inVector->n; 270 271 inVec = inVector->data.V; 271 272 inType = inVector->type.type; 272 273 273 274 if ( outVector == NULL ) { 274 outVector = psVectorAlloc( inN, PS_TYPE_U32 );275 outVector->n = inN;276 }277 275 outVector = psVectorAlloc( inN, PS_TYPE_U32 ); 276 outVector->n = inN; 277 } 278 278 279 outN = outVector->n; 279 280 outVec = outVector->data.V; 280 281 281 282 if ( inN != outN ) { 282 psError( __func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n",283 __LINE__, inN, outN );284 return outVector;285 }286 283 psError( __func__, " : Line %d - Input and output vector sizes are not equal: in=%d out=%d\n", 284 __LINE__, inN, outN ); 285 return outVector; 286 } 287 287 288 if ( outVector->type.type != PS_TYPE_U32 ) { 288 psError( __func__, " : Line %d - Output vector is not of type U32: out=%d\n",289 __LINE__, outVector->type.type );290 return outVector;291 }292 289 psError( __func__, " : Line %d - Output vector is not of type U32: out=%d\n", 290 __LINE__, outVector->type.type ); 291 return outVector; 292 } 293 293 294 tmpVector = psVectorAlloc( inN, inType ); 294 295 tmpVector->n = inN; 295 296 tmpVector = psVectorSort( tmpVector, inVector ); 296 297 297 298 // Sort output vector 298 299 switch ( inType ) { 299 case PS_TYPE_U8:300 SORT_INDICES( U8 );301 break;302 case PS_TYPE_U16:303 SORT_INDICES( U16 );304 break;305 case PS_TYPE_U32:306 SORT_INDICES( U32 );307 break;308 case PS_TYPE_U64:309 SORT_INDICES( U64 );310 break;311 case PS_TYPE_S8:312 SORT_INDICES( S8 );313 break;314 case PS_TYPE_S16:315 SORT_INDICES( S16 );316 break;317 case PS_TYPE_S32:318 SORT_INDICES( S32 );319 break;320 case PS_TYPE_S64:321 SORT_INDICES( S64 );322 break;323 case PS_TYPE_F32:324 SORT_INDICES( F32 );325 break;326 case PS_TYPE_F64:327 SORT_INDICES( F64 );328 break;329 default:330 psError( __func__, " : Line %d - Invalid psType\n", __LINE__ );331 }332 300 case PS_TYPE_U8: 301 SORT_INDICES( U8 ); 302 break; 303 case PS_TYPE_U16: 304 SORT_INDICES( U16 ); 305 break; 306 case PS_TYPE_U32: 307 SORT_INDICES( U32 ); 308 break; 309 case PS_TYPE_U64: 310 SORT_INDICES( U64 ); 311 break; 312 case PS_TYPE_S8: 313 SORT_INDICES( S8 ); 314 break; 315 case PS_TYPE_S16: 316 SORT_INDICES( S16 ); 317 break; 318 case PS_TYPE_S32: 319 SORT_INDICES( S32 ); 320 break; 321 case PS_TYPE_S64: 322 SORT_INDICES( S64 ); 323 break; 324 case PS_TYPE_F32: 325 SORT_INDICES( F32 ); 326 break; 327 case PS_TYPE_F64: 328 SORT_INDICES( F64 ); 329 break; 330 default: 331 psError( __func__, " : Line %d - Invalid psType\n", __LINE__ ); 332 } 333 333 334 // Free temp memory 334 335 psFree( tmpVector ); 335 336 336 337 return outVector; 337 338 } … … 340 341 { 341 342 if ( psVec == NULL ) { 342 return ;343 }344 343 return ; 344 } 345 345 346 psFree( psVec->data.V ); 346 347 } -
trunk/psLib/src/collections/psVector.h
r1233 r1385 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-0 7-15 23:52:33$13 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-08-04 23:37:39 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
Note:
See TracChangeset
for help on using the changeset viewer.
