psSpline.h

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

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1