Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psLookupTable.h

Go to the documentation of this file.
00001 /** @file  psLookupTable.h
00002 *
00003 *  @brief This file defines the structure and functions for table lookups.
00004 *
00005 *  @ingroup dataIO
00006 *
00007 *  @author Ross Harman, MHPCC
00008 *
00009 *  @version $Revision: 1.1.1.1 $ $Name:  $
00010 *  @date $Date: 2005/06/15 21:08:12 $
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     const char *format;                ///< scanf-like format string for file
00032     unsigned int indexCol;             ///< Column of the index vector (starting at zero)
00033     psVector *index;                   ///< Vector of independent index values
00034     psArray *values;                   ///< Array of dependent table values corresponding to index values
00035     psF64 validFrom;                   ///< Lower bound for rable read
00036     psF64 validTo;                     ///< Upper bound for table read
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     const char *format,             ///< scanf-like format string
00072     int indexCol                    ///< Column of the index vector (starting at zero)
00073 );
00074 
00075 /** Read vectors from file
00076  *
00077  *  Read numeric vectors from ASCII text file
00078  *
00079  *  @return psArray*  New array of psVectors corresponding to the columns of the table
00080  */
00081 psArray *psVectorsReadFromFile(
00082     const char* filename,            ///< File to be read
00083     const char* format               ///< scanf-like format string
00084 );
00085 
00086 /** Import arrays of vectors into a table
00087  *
00088  *  Import array of vectors read from text file into a table structure
00089  *
00090  *  @return psLookupTable*  Lookup table structure with array vector data
00091  */
00092 psLookupTable *psLookupTableImport(
00093     psLookupTable *table,            ///< Lookup table into which to import
00094     const psArray *vectors,          ///< Array of vectors
00095     int indexCol                     ///< Index of the index vector in the array of vectors
00096 );
00097 
00098 /** Read lookup table
00099  *
00100  *  Reads a lookup table and fills corresponding psLookupTable struct.
00101  *
00102  *  @return psS32     Number of valid lines read
00103  */
00104 psS32 psLookupTableRead(
00105     psLookupTable *table            ///< Table to read
00106 );
00107 
00108 /** Lookup and interpolate value from table.
00109  *
00110  *  Interpolates value from table. Sets status bit for success or one of several possible failure
00111  *  conditions.
00112  *
00113  *  @return psLookupTable*     New psLookupTable struct
00114  */
00115 psF64 psLookupTableInterpolate(
00116     const psLookupTable *table,     ///< Table with data
00117     psF64 index,                    ///< Value to be interpolated
00118     psS32 column                    ///< Column in table to be interpolated
00119 );
00120 
00121 /** Lookup and interpolate all values from table.
00122  *
00123  *  Interpolates all values from table. Sets status bit for success or one of several possible failure
00124  *  conditions.
00125  *
00126  *  @return psLookupTable*     New psLookupTable struct
00127  */
00128 psVector* psLookupTableInterpolateAll(
00129     psLookupTable *table,           ///< Table with data
00130     psF64 index                     ///< Value to be interpolated
00131 );
00132 
00133 #endif // #ifndef PS_LOOKUPTABLE_H

Generated on Wed Jun 15 11:00:57 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1