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

Functions

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

Function Documentation

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

Interpolation of Univariate Data

For a given set of data $(x_\ell,z_\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}) \]

subject to the interpolation constraints

\[ s(x_\ell) = z_\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}$. If the degree is even, then the knot vector ${\bf\Lambda}$ is defined such that its distinct knot vector is

\[ {\bf\rm K}^{\bf\Lambda} = (x_1,0.5(x_1+x_2),\cdots,0.5(x_{N-1}+x_N),x_N)^T \]

and; if the degree is odd, then ${\bf\Lambda}$ is defined such that its distinct knot vector is

\[ {\bf\rm K}^{\bf\Lambda} = (x_1,x_2,\cdots,x_{N-1},x_N)^T. \]

In either case, its corresponding knot multiplicity vector is

\[ {\bf\rm H}^{\bf\Lambda} = (d+1,1,\cdots,1,d+1)^T \]

and the number of spline coefficients $m$ is

\[ m = \cases{ N + d , & {\rm if the degree is even}; \cr N + d-1, & {\rm if the degree is odd}. \cr} \]

Since there are only $N$ interpolation constraints and $m\ge N$ coefficients, it is necessary to define additional conditions in order to insure an unique solution when $d>1$. Hence, this function imposes boundary conditions on the derivatives $s^{(p)}(x)$ of the spline at its left and right hand boundaries. These conditions are $s^{(p)}(x_1) = s^{(p)}(x_N) = 0.0$ for

\[ p = \cases{ {d\over 2 }+1,\ldots, d, & {\rm if the degree is even}; \cr {d+1\over 2} ,\ldots, d-1, & {\rm if the degree is odd}. \cr} \]

The following table summarizes the boundary conditions imposed for $2\le d\le 5$.

Degree Boundary Conditions
Quadratic $s^{(2)}(x_1) = 0.0 \hspace{5pt} {\rm and } \hspace{5pt} s^{(2)}(x_N) = 0.0$
Cubic $s^{(2)}(x_1) = 0.0 \hspace{5pt} {\rm and } \hspace{5pt} s^{(2)}(x_N) = 0.0$
Quartic $s^{(3)}(x_1) = s^{(4)}(x_1) = 0.0 \hspace{5pt} {\rm and }\hspace{5pt} s^{(3)}(x_N) = s^{(4)}(x_N) = 0.0$
Quintic $s^{(3)}(x_1) = s^{(4)}(x_1) = 0.0 \hspace{5pt} { \rm and }\hspace{5pt} s^{(3)}(x_N) = s^{(4)}(x_N) = 0.0$

This function performs the follow tasks:

  • Checks the input parameters for validity, see AMA_UnvInputCheck().
  • Defines the spline $s(x)$ based on the knot vector ${\bf\Lambda}$ described above.
  • Defines CNSPLA_CONPNT constraints to represent the interpolation constraints, see AMA_UnvConpnt().
  • Defines CNSPLA_CONPNT constraints to represent the boundary conditions.
  • Invokes cnspla to compute a spline which minimizes $F^{(2)}(s(x))$ subject to the interpolation constraints and boundary conditions.
  • Stores interpolant 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_UnvInterp().
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$.
degree[in] The degree $d$. Must satisfy $1\le$ degree $\le 5$.
spline[out] Pointer to AMA_SPLINE pointer containing the spline interpolant. Must satisfy spline $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 101715