Functions
AMA.c File Reference

Functions

long int AMA_LamdaInterp (AMA_OPTIONS *options, long int n, double *x, long int degree, long int *mlamda, double **lamda)
 Define Approximation and Interpolation Knot Vector More...
 
long int AMA_LamdaMonoInterp (AMA_OPTIONS *options, long int n, double *x, long int degree, enum AMA_Continuity continuity, long int *mlamda, double **lamda)
 Define Monotonic Spline Interpolation Knot Vector. More...
 

Function Documentation

long int AMA_LamdaInterp ( AMA_OPTIONS options,
long int  n,
double *  x,
long int  degree,
long int *  mlamda,
double **  lamda 
)

Define Approximation and Interpolation Knot Vector

For given independent variable data $x_\ell$, for $\ell=1,\ldots,N$, this function computes a knot vector ${\bf\Lambda}$ which insures a spline has sufficient coefficients to satisfy the approximation or interpolation constraints imposed by the univariate and multivariate data approximation and interpolation functions.

The knot vector ${\bf\Lambda}$ depends on the degree, $d$, of the spline approximation. If the degree is even, then the knot vector ${\bf\Lambda}\in{\rm R}^M$, where $M=N+2d+1$, is defined such that its distinct knots are

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

If the degree is odd, then the knot vector ${\bf\Lambda}\in{\rm R}^M$, where $M=N+2d$, is defined such that its distinct knots are

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

Regardless of the degree its corresponding knot multiplicity vector is

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

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_LamdaInterp().
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.
degree[in] The degree $d$. Must satisfy $1\le$ degree $\le 5$.
mlamda[out] The number of knots $M$. Must satisfy mlamda $\ne$ NULL.
lamda[out] Pointer to an array of size mlamda containing the knot vector ${\bf\Lambda}$. Must satisfy lamda $\ne$ NULL.
Returns
Success/Error Code.

User Support Function - Documented 110415 - !!!THIS IS NOT A USER CALLABLE FUNCTION - DOCUMENT IS INCLUDED FOR COMPLETENESS!!!

long int AMA_LamdaMonoInterp ( AMA_OPTIONS options,
long int  n,
double *  x,
long int  degree,
enum AMA_Continuity  continuity,
long int *  mlamda,
double **  lamda 
)

Define Monotonic Spline Interpolation Knot Vector.

For given independent variable data $x_\ell$, for $\ell=1,\ldots,N$, this function computes a knot vector ${\bf\Lambda}$ which insures a spline has sufficient coefficients to satisfy either the full continuity condition or the reduced continuity condition at the interior data points and also the approximation and local monotinicity constraints. The knot vector provides sufficient conditions to insure a feasible solution for the constraints independent of the variation of the dependent variable data. It depends on the spline's degree, $d$, and the continuity of the spline at the interior data points $x_\ell$, for $\ell=2,\ldots,N-1$.

If the spline is linear, $d=1$, then independent of the continuity condition the spline's value $s(x)$ is continuous at the interior data points and the knot vector ${\bf\Lambda}\in{\rm R}^{N+2}$ is defined such that its distinct knot and knot multiplicity vectors are

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

and

\[ {\bf\rm H}^{\bf\Lambda} = (2,1,\cdots,1,2). \]

The number of spline coefficients is $m=N$. If $2\le d\le 5$, then the knot vector ${\bf\Lambda}$ depends on whether the spline satisfies either a full continuity condition or a reduced continuity condition.

If a full continuity condition is requested, then the spline's value $s(x)$ and its derivatives $s^{(p)}(x)$, for $p=1,\ldots,d-1$, are continuous at $x_\ell$, for $\ell=2,\ldots,N-1$. In this case the knot vector ${\bf\Lambda}\in{\rm R}^{d(N+1)+1}$ is defined such that its distinct knots are

\[ \lambda_{(l-1)d+j} = \left({d-j+1 \over d}\right)x_\ell + \left({j-1 \over d}\right)x_{\ell+1} \]

for $\ell=1,\ldots,N-1$ and $j=1,\ldots,d$; and $\lambda_{d(N-1)+1} = x_N$. For example, if the spline is quadratic, $d=2$, then the distinct knot vector is

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

and; if if the spline is cubic, $d=3$, then the distinct knot vector is

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

Regardless of the degree 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 is $m=dN$. This distribution of knots insures the spline has sufficient coefficients to satisfy the full continuity condition at the interior data and to satisfy both the approximation and local monotinicity constraints independent of the variation of the dependent variable data $z_\ell$, for $l=1,\ldots,N$.

If a reduced continuity condition is requested, then the knot vector depends on the spline's degree. If the spline is quadratic, $d=2$, or cubic, $d=3$, then the knot vector ${\bf\Lambda}\in{\rm R}^{2(N+d-1)}$ is defined such that its distinct knot and knot multiplicity vectors are

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

and

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

The number of spline coefficients is $m=2N+d-3$.

If $4\le d\le 5$, then for each interval $[x_\ell,x_{\ell+1}]$, for $\ell=1,\ldots,N-1$, this function defines the knots

\[ \lambda_{\ell,j} = \left({d-j-2 \over d-2}\right)x_\ell + \left({j \over d-2}\right)x_{\ell+1} \]

for $j=1,\ldots,d-3$, of multiplicity one and knots of multiplicity two at the interior data points $x_\ell$, for $\ell=2,\ldots,N-1$, along with knots of multiplicity $d+1$ at the endpoints $x_1$ and $x_N$. That is, if the spline is quartic, $d=4$, then ${\bf\Lambda}\in{\rm R}^{3N+5}$ and its distinct knot and knot multiplicity vectors are

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

and

\[ {\bf\rm H}^{\bf\Lambda} = (5,1,2,\cdots,2,1,5). \]

The number of spline coefficients is $m=3N$. However, if the spline is quintic, $d=5$, then ${\bf\Lambda}\in{\rm R}^{4N+6}$ and its distinct knot and knot multiplicity vectors are

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

and

\[ {\bf\rm H}^{\bf\Lambda} = (6,1,2,\cdots,2,1,6). \]

The number of spline coefficients is $m=4N$. The distribution of knots discussed above insures the spline has sufficient coefficients to satisfy the reduced continuity condition at the interior data and to satisfy both the approximation and local monotinicity constraints independent of the variation of the dependent variable data $z_\ell$, for $l=1,\ldots,N$.

The following table summarizes the continuity of $s(x_\ell)$, for $\ell=2,\ldots,N-1$, and the number of coefficients, $m$, for a spline that satisfies the full and reduced continuity conditions.

Degree Full Continuity $m$ Reduced Continuity $m$
Linear $s^{(p)}(x_\ell)$ is continuous for $p=0$ $N$ $s^{(p)}(x_\ell)$ is continuous for $p=0$ $N$
Quadratic $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 1$ $2N$ $s^{(p)}(x_\ell)$ is continuous for $p=0$ $2N-1$
Cubic $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 2$ $3N$ $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 1$ $2N$
Quartic $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 3$ $4N$ $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 2$ $3N$
Quintic $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 4$ $5N$ $s^{(p)}(x_\ell)$ is continuous for $0\le p\le 3$ $4N$
Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_LamdaMonoInterp().
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.
degree[in] The degree $d$. Must satisfy $1\le$ degree $\le 5$.
continuity[in] Continuity condition flag. It has one of the following two values:
  • If continuity equals AMA_Continuity_Full, then spline approximation or interpolant satisfies the full continuity condition in $x_k$.
  • If continuity equals AMA_Continuity_Reduced, then spline approximation or interpolant satisfies the reduced continuity condition in $x_k$.
mlamda[out] The number of knots $M$. Must satisfy mlamda $\ne$ NULL.
lamda[out] Pointer to an array of size mlamda containing the knot vector ${\bf\Lambda}$. Must satisfy lamda $\ne$ NULL.
Returns
Success/Error Code.

User Support Function - Documented 110415 - !!!THIS IS NOT A USER CALLABLE FUNCTION - DOCUMENT IS INCLUDED FOR COMPLETENESS!!!