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 * @ingroup GROUP00 00009 * 00010 * @author GLG, MHPCC 00011 * 00012 * @version $Revision: 1.1.1.1 $ $Name: $ 00013 * @date $Date: 2005/09/14 20:42:48 $ 00014 * 00015 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00016 */ 00017 00018 #ifndef PS_SPLINE_H 00019 #define PS_SPLINE_H 00020 00021 #include <stdio.h> 00022 #include <stdbool.h> 00023 #include <float.h> 00024 #include <math.h> 00025 00026 #include "psVector.h" 00027 #include "psScalar.h" 00028 #include "psPolynomial.h" 00029 00030 /** \addtogroup GROUP00 00031 * \{ 00032 */ 00033 00034 /** One-Dimensional Spline */ 00035 typedef struct 00036 { 00037 int n; ///< The number of spline pieces 00038 psPolynomial1D **spline; ///< An array of n pointers to the spline polynomials 00039 psVector *knots; ///< The boundaries between each spline piece. Size is n+1. 00040 psF32 *p_psDeriv2; ///< For cubic splines, the second derivative at each domain point. Size is n+1. 00041 psF32 *p_psDomains; ///< The boundaries between each spline piece. Size is n+1. 00042 } 00043 psSpline1D; 00044 00045 /** Allocates a psSpline1D structure 00046 * 00047 * Allocator for psSpline1D where the bounds are implicitly specified through specifying 00048 * min and max values along with the number of splines. 00049 * 00050 * @return psSpline1D* new 1-D spline struct 00051 */ 00052 psSpline1D *psSpline1DAlloc( 00053 int n, ///< Number of spline polynomials 00054 int order, ///< Order of spline polynomials 00055 float min, ///< Lower boundary value of spline polynomials 00056 float max ///< Upper boundary value of spline polynomials 00057 ); 00058 00059 /** Allocates a psSpline1D structure 00060 * 00061 * Allocator for psSpline1D where the bounds are explicitly specified. 00062 * 00063 * @return psSpline1D* new 1-D spline struct 00064 */ 00065 psSpline1D *psSpline1DAllocGeneric( 00066 const psVector *bounds, ///< Bounds for spline polynomials 00067 int order ///< Order of spline polynomials 00068 ); 00069 00070 /** Evaluates 1-D spline polynomials at a specific coordinate. 00071 * 00072 * @return float result of spline polynomials evaluated at given location 00073 */ 00074 float psSpline1DEval( 00075 const psSpline1D *spline, ///< Coefficients for spline polynomials 00076 float x ///< location at which to evaluate 00077 ); 00078 00079 /** Evaluates 1-D spline polynomials at a set of specific coordinates. 00080 * 00081 * @return psVector* results of spline polynomials evaluated at given locations 00082 */ 00083 psVector *psSpline1DEvalVector( 00084 const psSpline1D *spline, ///< Coefficients of spline polynomials 00085 const psVector *x ///< locations at which to evaluate 00086 ); 00087 00088 /** Performs a binary disection on a given vector. 00089 * Searches through an array of data for a specified value. 00090 * 00091 * @return psS32 corresponding index number of specified value 00092 */ 00093 psS32 p_psVectorBinDisect( 00094 psVector *bins, ///< Array of non-decreasing values 00095 psScalar *x ///< Target value to find 00096 ); 00097 00098 /** Interpolates a series of data points for evaluation at a specific coordinate. Uses a 00099 * Lagrange interpolation method. 00100 * 00101 * @return psScalar* Lagrange interpolation value at given location 00102 */ 00103 psScalar *p_psVectorInterpolate( 00104 psVector *domain, ///< Domain (x coords) for interpolation 00105 psVector *range, ///< Range (y coords) for interpolation 00106 int order, ///< Order of interpolation function 00107 psScalar *x ///< Location at which to evaluate 00108 ); 00109 00110 /** Checks the type of a particular pointer. 00111 * 00112 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 00113 * 00114 * @return bool: True if the pointer matches a psSpline1D structure, false otherwise. 00115 */ 00116 bool psMemCheckSpline1D( 00117 psPtr ptr ///< the pointer whose type to check 00118 ); 00119 00120 /** Derive a one-dimensional spline fit. 00121 * 00122 * Given a psSpline1D data structure and a set of x,y vectors, this routine 00123 * generates the linear splines which satisfy those data points. 00124 * 00125 * @return psSpline1D*: the calculated one-dimensional splines 00126 */ 00127 psSpline1D *psVectorFitSpline1D( 00128 psSpline1D *mySpline, ///< The spline which will be generated. 00129 const psVector* x, ///< Ordinates (or NULL to just use the indices) 00130 const psVector* y, ///< Coordinates 00131 const psVector* yErr ///< Errors in coordinates, or NULL 00132 ); 00133 00134 psSpline1D *psVectorFitSpline1DNEW( 00135 const psVector* x, ///< Ordinates (or NULL to just use the indices) 00136 const psVector* y, ///< Coordinates 00137 int nKnots 00138 ); 00139 00140 /** \} */ // End of MathGroup Functions 00141 00142 #endif // #ifndef PS_SPLINE_H 00143
1.4.2