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.58 $ $Name: rel9_0 $ 00015 * @date $Date: 2005/11/15 20:10:32 $ 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 /** \addtogroup GROUP00 00033 * \{ 00034 */ 00035 00036 /** One-Dimensional Spline */ 00037 typedef struct 00038 { 00039 unsigned int n; ///< The number of spline pieces 00040 psPolynomial1D **spline; ///< An array of n pointers to the spline polynomials 00041 psVector *knots; ///< The boundaries between each spline piece. Size is n+1. 00042 psF32 *p_psDeriv2; ///< For cubic splines, the second derivative at each domain point. Size is n+1. 00043 } 00044 psSpline1D; 00045 00046 /** Allocates a psSpline1D structure 00047 * 00048 * Allocator for psSpline1D. 00049 * 00050 * @return psSpline1D* new 1-D spline struct 00051 */ 00052 psSpline1D *psSpline1DAlloc(); 00053 00054 /** Evaluates 1-D spline polynomials at a specific coordinate. 00055 * 00056 * @return float result of spline polynomials evaluated at given location 00057 */ 00058 float psSpline1DEval( 00059 const psSpline1D *spline, ///< Coefficients for spline polynomials 00060 float x ///< location at which to evaluate 00061 ); 00062 00063 /** Evaluates 1-D spline polynomials at a set of specific coordinates. 00064 * 00065 * @return psVector* results of spline polynomials evaluated at given locations 00066 */ 00067 psVector *psSpline1DEvalVector( 00068 const psSpline1D *spline, ///< Coefficients of spline polynomials 00069 const psVector *x ///< locations at which to evaluate 00070 ); 00071 00072 /** Derive a one-dimensional spline fit. 00073 * 00074 * Given a psSpline1D data structure and a set of x,y vectors, this routine 00075 * generates the linear splines which satisfy those data points. 00076 * 00077 * @return psSpline1D*: the calculated one-dimensional splines 00078 */ 00079 psSpline1D *psVectorFitSpline1D( 00080 const psVector* x, ///< Ordinates (or NULL to just use the indices) 00081 const psVector* y ///< Coordinates 00082 ); 00083 00084 /** Checks the type of a particular pointer. 00085 * 00086 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 00087 * 00088 * @return bool: True if the pointer matches a psSpline1D structure, false otherwise. 00089 */ 00090 bool psMemCheckSpline1D( 00091 psPtr ptr ///< the pointer whose type to check 00092 ); 00093 00094 /** Performs a binary disection on a given vector. 00095 * Searches through an array of data for a specified value. 00096 * 00097 * @return psS32 corresponding index number of specified value 00098 */ 00099 psS32 p_psVectorBinDisect( 00100 psVector *bins, ///< Array of non-decreasing values 00101 psScalar *x ///< Target value to find 00102 ); 00103 00104 /** Interpolates a series of data points for evaluation at a specific coordinate. Uses a 00105 * Lagrange interpolation method. 00106 * 00107 * @return psScalar* Lagrange interpolation value at given location 00108 */ 00109 psScalar *p_psVectorInterpolate( 00110 psVector *domain, ///< Domain (x coords) for interpolation 00111 psVector *range, ///< Range (y coords) for interpolation 00112 psS32 order, ///< Order of interpolation function 00113 psScalar *x ///< Location at which to evaluate 00114 ); 00115 00116 /** \} */ // End of MathGroup Functions 00117 00118 #endif // #ifndef PS_SPLINE_H 00119
1.4.2