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

Functions

long int AMA_SplineCheck (AMA_OPTIONS *options, AMA_SPLINE *spline)
 Check Validity of Spline Structure More...
 
long int AMA_SplineFree (AMA_OPTIONS *options, AMA_SPLINE **spline)
 Free a Spline Structure More...
 
long int AMA_SplineIntegral (AMA_OPTIONS *options, long int *porder, AMA_SPLINE *spline, AMA_SPLINE **integral)
 Analytic Integral of a Spline More...
 
long int AMA_SplinePartial (AMA_OPTIONS *options, long int *porder, AMA_SPLINE *spline, AMA_SPLINE **partial)
 Analytic Partial of a Spline More...
 
long int AMA_SplinePartialValue (AMA_OPTIONS *options, double *x, long int *porder, AMA_SPLINE *spline, double *sval)
 Evaluate Partial Derivative of a Spline More...
 
long int AMA_SplineRead (AMA_OPTIONS *options, const char *splfile, const char *type, AMA_SPLINE **spline)
 Read a Spline More...
 
long int AMA_SplineValue (AMA_OPTIONS *options, double *x, AMA_SPLINE *spline, double *sval)
 Evaluate a Spline More...
 
long int AMA_SplineWrite (AMA_OPTIONS *options, const char *splfile, const char *type, AMA_SPLINE *spline)
 Write a Spline More...
 
double AMA_SplineInfbnd (void)
 Define a finite number which represents an infinite bound. More...
 

Function Documentation

long int AMA_SplineCheck ( AMA_OPTIONS options,
AMA_SPLINE spline 
)

Check Validity of Spline Structure

This function determines if the AMA_SPLINE structure which represents the spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}) \]

is properly defined. It insures the following conditions are satisfied:

Additionally, for each knot vector ${\bf\Lambda}_k$, for $1\le k\le n$, defined as

\[ {\bf\Lambda}_k = ( \lambda_{k,1},\cdots,\lambda_{k,d_k+1}, \lambda_{k,d_k+2}, \cdots, \lambda_{k,m_k}, \lambda_{k,m_k+1},\cdots,\lambda_{k,m_k+d_k+1} )^T \]

this function insures the following conditions are satisfied:

  • $\lambda_{k,1} = \ldots = \lambda_{k,d_k+1}$;
  • $\lambda_{k,i} \le \lambda_{k,i+1}$, for $1\le i\le m_k+d_k$;
  • $\lambda_{k,i} < \lambda_{i+d_k+1}$, for $1\le i\le m_k$; and
  • $\lambda_{k,m_k+1} = \ldots = \lambda_{k,m_k+d_k+1}$.
Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineCheck().
spline[in] Pointer to AMA_SPLINE structure to check. Must satisfy spline $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 112514

long int AMA_SplineFree ( AMA_OPTIONS options,
AMA_SPLINE **  spline 
)

Free a Spline Structure

This function frees an AMA_SPLINE structure which represents the spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}). \]

This function does the following:

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineFree().
spline[in] Pointer to AMA_SPLINE pointer containing structure to free. Must satisfy spline $\ne$ NULL and be a valid AMA_SPLINE structure, see AMA_SplineCheck().
Returns
Success/Error Code.

User Callable Function - Documented 112514

double AMA_SplineInfbnd ( void  )

Define a finite number which represents an infinite bound.

This function defines the finite number $\alpha_\infty = 0.01\times {\rm DBL\_EPSILON}^{-1}$ which represents an infinite bound. By default the univariate splines are subject to the bounds

\[ \alpha_l \le s(x) \le \alpha_u \]

and the multivariate splines are subject to the bounds

\[ \alpha_l \le s({\bf X}) \le \alpha_u, \]

where $\alpha_l = -\alpha_\infty$ and $\alpha_u = \alpha_\infty$. Therefore, the splines are unbounded but finite bounds can be set with AMA_OptionsSetBounds().

Returns
$\alpha_\infty$.

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

long int AMA_SplineIntegral ( AMA_OPTIONS options,
long int *  porder,
AMA_SPLINE spline,
AMA_SPLINE **  integral 
)

Analytic Integral of a Spline

For a spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}) \]

this function computes the indefinite integral

\[ \int\cdots\int s({\bf X}) dx_1\cdots dx_n. \]

The integral with respect to $x_k$ is computed $p_k$ times, for $1\le k\le n$; where $p_k = 0$ or $p_k = 1$.

Parameter Note: In the parameter descriptions given below the limits on $k$ are $1\le k\le n$ and k $= k-1$.

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineIntegral().
porder[in] Array of size $n$ containing the integral order $p_k$ where porder[k] $= p_k$. Must satisfy porder[k] $= 0$ or porder[k] $= 1$.
spline[in] Pointer to AMA_SPLINE containing the spline to integrate. Must be a valid AMA_SPLINE structure, see AMA_SplineCheck().
integral[out] Pointer to AMA_SPLINE pointer containing the spline's indefinite integral. Must satisfy integral $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 021116

long int AMA_SplinePartial ( AMA_OPTIONS options,
long int *  porder,
AMA_SPLINE spline,
AMA_SPLINE **  partial 
)

Analytic Partial of a Spline

For a spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}) \]

this function computes the partial derivative

\[ {\partial^{q} s({\bf X})\over \partial x^{p_1}_1\cdots\partial x^{p_n}_n} \]

where the partial order $q=\sum_{k=1}^np_k$ and $p_k$ is the partial order in $x_k$, for $1\le k\le n$.

Parameter Note: In the parameter descriptions given below the limits on $k$ are $1\le k\le n$ and k $= k-1$.

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplinePartial().
porder[in] Array of size $n$ containing the partial order $p_k$ where porder[k] $= p_k$. Must satisfy porder[k] $\ge 0$.
spline[in] Pointer to AMA_SPLINE containing the spline to differentiate. Must be a valid AMA_SPLINE structure, see AMA_SplineCheck().
partial[out] Pointer to AMA_SPLINE pointer containing the spline's partial derivative. Must satisfy partial $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 021116

long int AMA_SplinePartialValue ( AMA_OPTIONS options,
double *  x,
long int *  porder,
AMA_SPLINE spline,
double *  sval 
)

Evaluate Partial Derivative of a Spline

For a spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}) \]

this function evaluates the partial derivative

\[ {\partial^{q}s({\bf X}) \over \partial x_1^{p_1}\cdots\partial x_n^{p_n}} \]

of the spline at a point ${\bf X}^o = (x^o_1,\cdots,x^o_n)$. The partial order $q$ is $q = \sum_{k=1}^np_k$ where $p_k$ is the partial order in $u_k$, for $1\le k\le n$. The value of ${\bf X}^o$ must lie within the spline's domain; that is, if the knot vector ${\bf\Lambda}_k$ is defined as

\[ {\bf\Lambda}_k = ( \lambda_{k,1},\cdots,\lambda_{k,d_k+1}, \lambda_{k,d_k+2}, \cdots, \lambda_{k,m_k}, \lambda_{k,m_k+1},\cdots,\lambda_{k,m_k+d_k+1} )^T, \]

then $x^o_k$ must satisfy $\lambda_{k,1}\le x^o_k \le \lambda_{k,m_k+d_k+1}$, for all $1\le k\le n$. However, extrapolation can be enabled with AMA_OptionsSetExtrapolation().

Parameter Note: In the parameter descriptions given below the limits on $k$ are $1\le k\le n$ and k $= k-1$.

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplinePartialValue().
x[in] Array of size $n$ containing the evaluation point ${\bf X}^o$ where x[k] $= x^o_k$.
porder[in] Array of size $n$ containing the partial order $p_k$ where porder[k] $ = p_k$. Must satisfy $0\le$ porder[k] $\le d_k$. However, if the spline is linear in $x_k$, $d_k = 1$; then porder[k] can satisfy $0\le$ porder[k] $\le 2$.
spline[in] Pointer to AMA_SPLINE containing the spline whose partial derivative is evaluated. Must satisfy spline $\ne$ NULL.
sval[out] The value of the partial derivative of $s({\bf X})$ at ${\bf X}^o$. Must satisfy sval $\ne$ NULL.
Returns
Success/Error Code.
Note
For efficiency purposes this function does not check if spline is a valid AMA_SPLINE structure. Also, except for insuring the options parameter is properly initialized, all input error checking can be disabled with AMA_OptionsSetInputCheck().
If ${\bf X}^o$ lies outside of the spline's domain; then this function returns AMA_EXTRAPOLATION if extrapolation is enabled and AMA_INPUT_ERROR, otherwise.
If an input error occurs, then this function returns sval equal to DBL_MAX.

User Callable Function - Documented 021116

long int AMA_SplineRead ( AMA_OPTIONS options,
const char *  splfile,
const char *  type,
AMA_SPLINE **  spline 
)

Read a Spline

This function allocates and reads a spline from either an ascii or binary file.

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineRead().
splfile[in] Name of file from which spline is read.
type[in] Format of splfile. Must equal either ascii or binary. The value of type is not case sensitive.
spline[out] Pointer to AMA_SPLINE pointer containing the spline read from splfile. Must satisfy spline $\ne$ NULL.
Returns
Success/Error Code.

User Callable Function - Documented 021116

long int AMA_SplineValue ( AMA_OPTIONS options,
double *  x,
AMA_SPLINE spline,
double *  sval 
)

Evaluate a Spline

For a spline $s({\bf X}):{\rm R}^n\rightarrow {\rm R}^1$ given as

\[ s({\bf X}) = \sum_{j_n=1}^{m_n}\cdots\sum_{j_1=1}^{m_1}\alpha_{j_1,\ldots,j_n}B_{d_1,j_1}(x_1|{\bf\Lambda}_1)\cdots B_{d_n,j_n}(x_n|{\bf\Lambda_n}) \]

this function evaluates the spline at a point ${\bf X}^o = (x^o_1,\cdots,x^o_n)$. The value of ${\bf X}^o$ must lie within the spline's domain; that is, if the knot vector ${\bf\Lambda}_k$ is defined as

\[ {\bf\Lambda}_k = ( \lambda_{k,1},\cdots,\lambda_{k,d_k+1}, \lambda_{k,d_k+2}, \cdots, \lambda_{k,m_k}, \lambda_{k,m_k+1},\cdots,\lambda_{k,m_k+d_k+1} )^T, \]

then $x^o_k$ must satisfy $\lambda_{k,1}\le x^o_k \le \lambda_{k,m_k+d_k+1}$, for all $1\le k\le n$. However, extrapolation can be enabled with AMA_OptionsSetExtrapolation().

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineValue().
x[in] Array of size $n$ containing the evaluation point ${\bf X}^o$ where x[k] $= x^o_k$, for $1\le k\le n$ and k $= k - 1$.
spline[in] Pointer to AMA_SPLINE containing the spline to evaluate. Must satisfy spline $\ne$ NULL.
sval[out] The value of $s({\bf X}^o)$. Must satisfy sval $\ne$ NULL.
Returns
Success/Error Code.
Note
For efficiency purposes this function does not check if spline is a valid AMA_SPLINE structure. Also, except for insuring the options parameter is properly initialized, all input error checking can be disabled with AMA_OptionsSetInputCheck().
If ${\bf X}^o$ lies outside of the spline's domain; then this function returns AMA_EXTRAPOLATION if extrapolation is enabled and AMA_INPUT_ERROR, otherwise.
If an input error occurs, then this function returns sval equal to DBL_MAX.

User Callable Function - Documented 021116

long int AMA_SplineWrite ( AMA_OPTIONS options,
const char *  splfile,
const char *  type,
AMA_SPLINE spline 
)

Write a Spline

This function writes a spline to either an ascii or binary file.

Parameters
options[in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_SplineWrite().
splfile[in] Name of file to which spline is written.
type[in] Format of splfile. Must equal either ascii or binary. The value of type is not case sensitive.
spline[out] Pointer to AMA_SPLINE containing the spline to write to splfile. Must satisfy spline $\ne$ NULL and be a valid AMA_SPLINE structure, see AMA_SplineCheck().
Returns
Success/Error Code.

User Callable Function - Documented 021116