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

psSpline.h

Go to the documentation of this file.
00001 /** @file psSpline.h
00002  *  @brief Standard Mathematical Functions.
00003  *  @ingroup GROUP00
00004  *
00005  *  This file will hold the prototypes for procedures which allocate, free,
00006  *  and evaluate splines.
00007  *
00008  *  XXX: What is the purpose of the SplineAlloc() function?
00009  *
00010  *  @ingroup GROUP00
00011  *
00012  *  @author GLG, MHPCC
00013  *
00014  *  @version $Revision: 1.60 $ $Name: rel12 $
00015  *  @date $Date: 2006/06/30 02:20:06 $
00016  *
00017  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00018  */
00019 
00020 #ifndef PS_SPLINE_H
00021 #define PS_SPLINE_H
00022 
00023 #include <stdio.h>
00024 #include <stdbool.h>
00025 #include <float.h>
00026 #include <math.h>
00027 
00028 #include "psVector.h"
00029 #include "psScalar.h"
00030 #include "psPolynomial.h"
00031 
00032 #define PS_LEFT_SPLINE_DERIV 0.0
00033 #define PS_RIGHT_SPLINE_DERIV 0.0
00034 
00035 /** \addtogroup GROUP00
00036  *  \{
00037  */
00038 
00039 /** One-Dimensional Spline */
00040 typedef struct
00041 {
00042     unsigned int n;                    ///< The number of spline pieces
00043     psPolynomial1D **spline;           ///< An array of n pointers to the spline polynomials
00044     psVector *knots;                   ///< The boundaries between each spline piece.  Size is n+1.
00045     psF32 *p_psDeriv2;                 ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
00046 }
00047 psSpline1D;
00048 
00049 /** Allocates a psSpline1D structure
00050  *
00051  *  Allocator for psSpline1D.
00052  *
00053  *  @return psSpline1D*    new 1-D spline struct
00054  */
00055 psSpline1D *psSpline1DAlloc();
00056 
00057 /** Evaluates 1-D spline polynomials at a specific coordinate.
00058  *
00059  *  @return float    result of spline polynomials evaluated at given location
00060  */
00061 float psSpline1DEval(
00062     const psSpline1D *spline,          ///< Coefficients for spline polynomials
00063     float x                            ///< location at which to evaluate
00064 );
00065 
00066 /** Evaluates 1-D spline polynomials at a set of specific coordinates.
00067  *
00068  *  @return psVector*    results of spline polynomials evaluated at given locations
00069  */
00070 psVector *psSpline1DEvalVector(
00071     const psSpline1D *spline,          ///< Coefficients of spline polynomials
00072     const psVector *x                  ///< locations at which to evaluate
00073 );
00074 
00075 /** Derive a one-dimensional spline fit.
00076  *
00077  *  Given a psSpline1D data structure and a set of x,y vectors, this routine
00078  *  generates the linear splines which satisfy those data points.
00079  *
00080  *  @return psSpline1D*:  the calculated one-dimensional splines
00081  */
00082 psSpline1D *psVectorFitSpline1D(
00083     const psVector* x,                 ///< Ordinates (or NULL to just use the indices)
00084     const psVector* y                  ///< Coordinates
00085 );
00086 
00087 /** Checks the type of a particular pointer.
00088  *
00089  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00090  *
00091  *  @return bool:       True if the pointer matches a psSpline1D structure, false otherwise.
00092  */
00093 bool psMemCheckSpline1D(
00094     psPtr ptr                          ///< the pointer whose type to check
00095 );
00096 
00097 /*****************************************************************************
00098     PS_SPLINE macros:
00099 *****************************************************************************/
00100 #define PS_ASSERT_SPLINE(NAME, RVAL) \
00101 if (false == psMemCheckSpline1D(NAME)) { \
00102     psError(PS_ERR_BAD_PARAMETER_NULL, true, \
00103             "Unallowable operation: argument %s is not a psSpline1D struct.\n",\
00104             #NAME); \
00105     return(RVAL); \
00106 } \
00107 
00108 #define PS_ASSERT_SPLINE_NON_NULL(NAME, RVAL) \
00109 if ((NAME) == NULL) { \
00110     psError(PS_ERR_BAD_PARAMETER_NULL, true, \
00111             "Unallowable operation: psSpline1D %s is NULL.", \
00112             #NAME); \
00113     return(RVAL); \
00114 } \
00115 
00116 
00117 /** \} */ // End of MathGroup Functions
00118 
00119 #endif // #ifndef PS_SPLINE_H
00120 

Generated on Mon Jul 3 14:13:44 2006 for Pan-STARRS Foundation Library by  doxygen 1.4.4