Index: /trunk/doc/pslib/ChangeLogSDRS.tex
===================================================================
--- /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 2187)
+++ /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 2188)
@@ -1,3 +1,3 @@
-%%% $Id: ChangeLogSDRS.tex,v 1.36 2004-10-21 21:54:57 price Exp $
+%%% $Id: ChangeLogSDRS.tex,v 1.37 2004-10-21 22:40:25 price Exp $
 
 \subsection{Changes from version 00 to version 01}
@@ -352,3 +352,5 @@
 \item In \code{psVectorStats} and \code{psVectorHistogram}, the \code{errors}
 vector must be of the same type as the input values vector.
+\item Added \code{psLookupTable} section, and removed
+  \code{psTimeTableInterpolate} (now redundant).
 \end{itemize}
Index: /trunk/doc/pslib/psLibSDRS.tex
===================================================================
--- /trunk/doc/pslib/psLibSDRS.tex	(revision 2187)
+++ /trunk/doc/pslib/psLibSDRS.tex	(revision 2188)
@@ -1,3 +1,3 @@
-%%% $Id: psLibSDRS.tex,v 1.139 2004-10-21 21:55:03 price Exp $
+%%% $Id: psLibSDRS.tex,v 1.140 2004-10-21 22:39:57 price Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -1717,4 +1717,67 @@
 \code{psHash} table as a linked list.
 
+\subsection{Lookup Tables}
+
+Lookup tables store a variety of values indexed on a certain column.
+An example is for storing the difference between UT1 and UTC, and the
+polar motion vector as a function of date.
+
+\begin{verbatim}
+typedef struct {
+    psVector *index;                    ///< Index values
+    psArray *values;                    ///< Corresponding values: an array of vectors
+} psLookupTable;
+\end{verbatim}
+
+\code{index} shall contain the index values, which shall be sorted in
+increasing order.  The \code{values} shall consist of an array of
+vectors, each of the same length as the \code{index} vector.  The
+vectors (including the \code{index} and all vectors in the
+\code{values} array) may be any numerical type except complex types.
+
+The constructor shall be:
+\begin{verbatim}
+psLookupTable *psLookupTableAlloc(int numValues);
+\end{verbatim}
+Here the \code{numValues} indicates the number of vectors in the
+\code{values} array.
+
+The destructor shall also free the components.
+
+\begin{verbatim}
+psLookupTable *psLookupTableRead(const char *filename, int numValues);
+\end{verbatim}
+\code{psLookupTableRead} shall read the file specified by
+\code{filename} and import the data into a \code{psLookupTable}.  The
+file shall be plain text, with index and values on separate lines,
+separated by whitespace.  Lines commencing with a comment character
+(the pound sign, \code{#}) and blank lines shall be ignored.
+\code{numValues} in addition to the index shall be read on each line.
+If the \code{index} vector is not sorted in the file, the lookup table
+shall be sorted prior to the function returning, but no sort shall be
+performed if the indices were sorted in the file.
+
+Interpolation on a lookup table is performed by the following
+functions:
+\begin{verbatim}
+psF64 psLookupTableInterpolate(psLookupTable *table, psF64 index, int column);
+psVector *psLookupTableInterpolateAll(psLookupTable *table, psF64 index);
+\end{verbatim}
+Both functions shall interpolate the \code{table} at the provided
+\code{index}.  For \code{psLookupTableInterpolate}, only the value in
+the specified \code{column} shall be calculated and returned.  For
+\code{psLookupTableInterpolateAll}, all the values shall be calculated
+and returned as a \code{psVector}, the type of which shall be
+\code{PS_TYPE_F64}.  If the \code{index} is beyond the range of the
+\code{table}, \code{psLookupTableInterpolate} shall return \code{NaN},
+and \code{psLookupTableInterpolateAll} shall return \code{NULL} ---
+that is, no attempt is made at extrapolation.
+
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \section{Data manipulation}
 
@@ -1732,6 +1795,4 @@
 \item Minimization and fitting routines.
 \end{itemize}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \subsection{BitSets}
@@ -3410,8 +3471,6 @@
 PSLib).  The format of these files shall be simple, for speed in
 reading: Each line shall contain the MJD, $x_p$ (in arcseconds), $y_p$
-(in arcseconds) and $\Delta$UT (in seconds) separated by whitespace;
-blank lines and lines commencing with the comment character (the hash
-symbol, \code{#}) as the first character shall be ignored.  For
-example:
+(in arcseconds) and $\Delta$UT (in seconds) in a format readable by
+\code{psLookupTableRead}.  For example:
 
 \begin{verbatim}
@@ -3446,8 +3505,5 @@
     const char *filename;               // Filename of time table
     const psF64 validFrom, validTo;     // MJDs of validity of time table
-    bool loaded;                        // Has the table been loaded?
-    psVector *mjd;                      // MJD data, type is psF64
-    psVector *dut;                      // delta UT = UT1 - UTC data
-    psVector *xp, *yp;                  // Polar motion data
+    psLookupTable *table;	        // Lookup table indexed on MJD, with UT1-UTC, xp and yp
 } psTimeTable;
 \end{verbatim}
@@ -3473,19 +3529,19 @@
 \end{verbatim}
 
-Given a time \code{table} and a Modified Julian Date, \code{mjd}, at
-which to interpolate values, \code{psTimeTableInterpolate} shall
-calculate the appropriate UT1-UTC (\code{dut}; if non-\code{NULL}),
-and polar motion (\code{xp,yp}; if non-\code{NULL}) by interpolation
-on the table.  If the \code{mjd} is outside the range of the table or
-the interpolation was for some other reason unsuccessful, then the
-function shall return \code{false}; otherwise the function shall set
-those parameters which are non-\code{NULL} (\code{dut,xp,yp}) and
-return \code{true}.  If the requested \code{mjd} lies in the range of
-the \code{table}, but the \code{table} has not been \code{loaded},
-then the function shall call \code{psTimeTableLoad}.
-\begin{verbatim}
-bool psTimeTableInterpolate(const psTimeTable *table, double *xp,
-                            double *yp, double *dut, psF64 mjd);
-\end{verbatim}
+%Given a time \code{table} and a Modified Julian Date, \code{mjd}, at
+%which to interpolate values, \code{psTimeTableInterpolate} shall
+%calculate the appropriate UT1-UTC (\code{dut}; if non-\code{NULL}),
+%and polar motion (\code{xp,yp}; if non-\code{NULL}) by interpolation
+%on the table.  If the \code{mjd} is outside the range of the table or
+%the interpolation was for some other reason unsuccessful, then the
+%function shall return \code{false}; otherwise the function shall set
+%those parameters which are non-\code{NULL} (\code{dut,xp,yp}) and
+%return \code{true}.  If the requested \code{mjd} lies in the range of
+%the \code{table}, but the \code{table} has not been \code{loaded},
+%then the function shall call \code{psTimeTableLoad}.
+%\begin{verbatim}
+%bool psTimeTableInterpolate(const psTimeTable *table, double *xp,
+%                            double *yp, double *dut, psF64 mjd);
+%\end{verbatim}
 
 \paragraph{Time Metadata}
