Changeset 12329
- Timestamp:
- Mar 8, 2007, 12:08:26 PM (19 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
-
psLookupTable.c (modified) (6 diffs)
-
psLookupTable.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psLookupTable.c
r12287 r12329 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 49$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-03-0 7 02:42:22$9 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-03-08 22:08:26 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 197 197 psFree(table->filename); 198 198 psFree(table->format); 199 psFree(table->index); 199 200 } 200 201 … … 419 420 } 420 421 421 psLookupTable *p_psLookupTableImport(const char *file, 422 unsigned int lineno, 423 const char *func, 424 psLookupTable *table, 425 psArray *vectors, 426 long indexCol) 427 { 428 PS_ASSERT_LOOKUPTABLE_NON_NULL(table, NULL); 429 PS_ASSERT_ARRAY_NON_NULL(vectors, NULL); 422 bool p_psLookupTableImport(const char *file, 423 unsigned int lineno, 424 const char *func, 425 psLookupTable *table, 426 psArray *vectors, 427 long indexCol) 428 { 429 PS_ASSERT_LOOKUPTABLE_NON_NULL(table, false); 430 PS_ASSERT_ARRAY_NON_NULL(vectors, false); 431 PS_ASSERT_INT_NONNEGATIVE(indexCol, false); 430 432 if (indexCol >= vectors->n) { 431 433 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Index column, %ld, is larger" 432 434 " than number of columns, %ld.", indexCol, vectors->n); 433 return NULL;435 return false; 434 436 } 435 437 … … 526 528 } 527 529 528 return t able;530 return true; 529 531 } 530 532 … … 533 535 PS_ASSERT_LOOKUPTABLE_NON_NULL(table, 0); 534 536 535 long numRows = 0;536 psArray* vectors = NULL;537 psLookupTable* outTable = NULL;538 539 537 // Read vectors from file specified in table 540 vectors = psVectorsReadFromFile(table->filename, table->format); 541 542 // Check for valid array after reading from file 543 if (vectors != NULL) { 544 545 // Import vector into table 546 outTable = psLookupTableImport(table, vectors, table->indexCol); 547 538 psArray *vectors = psVectorsReadFromFile(table->filename, table->format); // Vectors in file 539 if (!vectors) { 540 psError(PS_ERR_UNKNOWN, false, "Unable to read vectors from %s", table->filename); 541 return 0; 542 } 543 544 // Import vector into table 545 if (!psLookupTableImport(table, vectors, table->indexCol)) { 546 psError(PS_ERR_UNKNOWN, false, "Unable to import vectors from %s into lookup table.", 547 table->filename); 548 548 psFree(vectors); 549 550 // Update the number of rows read if outTable is not NULL 551 if (outTable != NULL) { 552 numRows = table->index->n; 553 } 554 } 555 556 // Return the number of lines read 557 return numRows; 549 return 0; 550 } 551 psFree(vectors); // Drop reference 552 553 return table->index->n; 558 554 } 559 555 … … 716 712 PS_ASSERT_VECTOR_NON_NULL(table->index, NULL); 717 713 PS_ASSERT_ARRAY_NON_NULL(table->values, NULL); 718 719 714 long numCols = table->values->n; 715 if (numCols == 0) { 716 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "No columns in lookup table from which to interpolate."); 717 return NULL; 718 } 719 720 720 psVector *outVector = psVectorAlloc(numCols, PS_TYPE_F64); 721 721 -
trunk/psLib/src/types/psLookupTable.h
r12289 r12329 6 6 * @author Ross Harman, MHPCC 7 7 * 8 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-03-0 7 02:50:15$8 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-03-08 22:08:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 130 130 */ 131 131 #ifdef DOXYGEN 132 psLookupTable *psLookupTableImport(132 bool psLookupTableImport( 133 133 psLookupTable *table, ///< Lookup table into which to import 134 134 const psArray *vectors, ///< Array of vectors … … 136 136 ); 137 137 #else // ifdef DOXYGEN 138 psLookupTable *p_psLookupTableImport(138 bool p_psLookupTableImport( 139 139 const char *file, ///< File of caller 140 140 unsigned int lineno, ///< Line number of caller
Note:
See TracChangeset
for help on using the changeset viewer.
