Functions
AMA_UnvApprox.c File Reference
#include <AMA.h>

Functions

long int AMA_UnvApprox (AMA_OPTIONS *options, long int n, double *x, double *z, double *epsilon, long int degree, AMA_SPLINE **spline)
 Approximation of Univariate Data More...
 

Function Documentation

long int AMA_UnvApprox ( AMA_OPTIONS options,
long int  n,
double *  x,
double *  z,
double *  epsilon,
long int  degree,
AMA_SPLINE **  spline 
)

Approximation of Univariate Data

For a given set of data $(x_\ell,z_\ell)$ and approximation tolerances $\epsilon_\ell$, for $\ell=1,\ldots,N$, this function employs cnspla to compute the spline

\[ s(x) = \sum_{j=1}^{m}\alpha_jB_{d,j}(x|{\bf\Lambda}) \]

that minimizes

\[ F^{(2)}(s(x)) = \int_{x_1}^{x_N}\left( s^{(2)}(x) \right)^2 dx \]

subject to the approximation constraints

\[ z_\ell - \epsilon_\ell \le s(x_\ell) \le z_\ell + \epsilon_\ell \]

for $\ell=1,\ldots,N$.

In the above definition of $s(x)$ the $\alpha_j$, for $j=1,\ldots,m$, are the coefficients of the $m$univariate B-splines $B_{d,j}(x|{\bf\Lambda})$ of degree $1\le d\le 5$ which are based on the knot vector ${\bf\Lambda}$. The knot vector ${\bf\Lambda}$ depends on the independent variable data and the degree and is defined by AMA_LamdaInterp().

This function does the following:

  • Checks the input parameters for validity, see AMA_UnvInputCheck().
  • Defines the spline $s(x)$ based on a knot vector defined by AMA_LamdaInterp().
  • Defines CNSPLA_CONPNT constraints to represent the approximation constraints, see AMA_UnvConpnt().
  • Defines CNSPLA_PNLTRM condition to represent the function $F^{(2)}(s(x))$, see AMA_UnvPnltrm().
  • Invokes cnspla to compute a spline which minimizes $ F^{(2)}(s(x))$ subject to the approximation constraints.
  • Stores approximation into spline.
Note
By default the spline coefficients are initialized to zero but a different initial value for the spline coefficients can be set with AMA_OptionsSetCoefficients().
Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_UnvApprox().
n[in] The number of data points $N$. Must satisfy n $\ge 2$.
x[in] Array of size n containing the independent variable data $x_\ell$, for $\ell=1,\ldots,N$. Must be in strictly ascending order.
z[in] Array of size n containing the dependent variable data $z_\ell$, for $\ell=1,\ldots,N$.
epsilon[in] Array of size n containing the approximation tolerances $\epsilon_\ell$, for $\ell=1,\ldots,N$. Must satisfy $\epsilon_\ell\ge 0.0$ for all $\ell=1,\ldots,N$. If epsilon = NULL, then this function uses $\epsilon_\ell = 0.0$ for all $\ell=1,\ldots,N$.
degree[in] The degree $d$. Must satisfy $1\le$ degree $\le 5$.
spline[out] Pointer to AMA_SPLINE pointer containing the spline approximation. Must satisfy spline $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 101715