00001 /** @file psLookupTable.h 00002 * 00003 * @brief This file defines the structure and functions for table lookups. 00004 * 00005 * @ingroup fileUtils 00006 * 00007 * @author Ross Harman, MHPCC 00008 * 00009 * @version $Revision: 1.4 $ $Name: rel5_0 $ 00010 * @date $Date: 2005/02/17 21:54:09 $ 00011 * 00012 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 00013 */ 00014 00015 #ifndef PS_LOOKUPTABLE_H 00016 #define PS_LOOKUPTABLE_H 00017 00018 #include "psType.h" 00019 #include "psVector.h" 00020 #include "psArray.h" 00021 00022 00023 /** Lookup table structure 00024 * 00025 * Holds table data read from external data files. 00026 * 00027 */ 00028 typedef struct 00029 { 00030 const char *fileName; ///< Name of file with table 00031 psU64 numRows; ///< Number of table rows 00032 psU64 numCols; ///< Number of table columns 00033 psF64 validFrom; ///< Lower bound for rable read 00034 psF64 validTo; ///< Upper bound for table read 00035 psVector *index; ///< Vector of independent index values 00036 psArray *values; ///< Array of dependent table values corresponding to index values 00037 } 00038 psLookupTable; 00039 00040 00041 /** Lookup table lookup status and error conditions 00042 * 00043 * Success, failure, and status conditions for table lookups. 00044 */ 00045 typedef enum { 00046 PS_LOOKUP_SUCCESS = 0x0000, ///< Table lookup succeeded 00047 PS_LOOKUP_PAST_TOP = 0x0101, ///< Lookup off top of table 00048 PS_LOOKUP_PAST_BOTTOM = 0x0102, ///< Lookup off bottom of table 00049 PS_LOOKUP_ERROR = 0x0104 ///< Any other type of lookup error 00050 } psLookupStatusType; 00051 00052 /** Lookup table parse status and error conditions 00053 * 00054 * Success, failure, and status conditions for table parsing. 00055 */ 00056 typedef enum { 00057 PS_PARSE_SUCCESS = 0x0000, ///< Table lookup succeeded 00058 PS_PARSE_ERROR_TYPE = 0x0101, ///< Error parsing type 00059 PS_PARSE_ERROR_VALUE = 0x0102, ///< Error parsing numerical value 00060 PS_PARSE_ERROR_GENERAL = 0x0104 ///< Any other type of lookup error 00061 }psParseErrorType; 00062 00063 /** Allocator for psLookupTable struct 00064 * 00065 * Allocates a new psLookupTable struct. 00066 * 00067 * @return psLookupTable* New psLookupTable struct. 00068 */ 00069 psLookupTable* psLookupTableAlloc( 00070 const char *fileName, ///< Name of file to read 00071 psF64 validFrom, ///< Lower bound for rable read 00072 psF64 validTo ///< Upper bound for table read 00073 ); 00074 00075 /** Read lookup table 00076 * 00077 * Reads a lookup table and fills corresponding psLookupTable struct. 00078 * 00079 * @return psLookupTable* New psLookupTable struct. 00080 */ 00081 psLookupTable* psLookupTableRead( 00082 psLookupTable *table ///< Table to read 00083 ); 00084 00085 /** Lookup and interpolate value from table. 00086 * 00087 * Interpolates value from table. Sets status bit for success or one of several possible failure 00088 * conditions. 00089 * 00090 * @return psLookupTable* New psLookupTable struct 00091 */ 00092 psF64 psLookupTableInterpolate( 00093 psLookupTable *table, ///< Table with data 00094 psF64 index, ///< Value to be interpolated 00095 psU64 column, ///< Column in table to be interpolated 00096 psLookupStatusType *status ///< Status of lookup 00097 ); 00098 00099 /** Lookup and interpolate all values from table. 00100 * 00101 * Interpolates all values from table. Sets status bit for success or one of several possible failure 00102 * conditions. 00103 * 00104 * @return psLookupTable* New psLookupTable struct 00105 */ 00106 psVector* psLookupTableInterpolateAll( 00107 psLookupTable *table, ///< Table with data 00108 psF64 index, ///< Value to be interpolated 00109 psVector *stats ///< Vector of status for each lookup 00110 ); 00111 00112 #endif
1.3.9.1