#include <cnspla.h>
#include <stdio.h>
#include <stdlib.h>
#include <AMA_Options.h>
#include <AMA_Unv.h>
#include <AMA_Mltv.h>
#include <AMA_Spline.h>
#include <AMA_Visit.h>
Go to the source code of this file.
Classes  
struct  ama_options 
This structure is used to maintain the AMA Spline Library environment. More...  
struct  ama_spline 
This structure is used to define a tensor product spline . More...  
Macros  
Success/Error Code  
The following macros are used to define error codes returned by AMA Spline Library Functions. See Success/Error Code for additional details.  
#define  AMA_NO_ERROR 0 
No errors occured during function execution. More...  
#define  AMA_WARNING_ERROR 1 
A warning error occured in one or more functions. More...  
#define  AMA_PROCESS_ERROR 2 
A process error occured in one or more functions. More...  
#define  AMA_INPUT_ERROR 3 
An invalid value of an input parameter defined by the user is passed to a function. More...  
#define  AMA_FATAL_ERROR 4 
An invalid value of an input parameter defined within an AMA Function is passed to another AMA Function. More...  
#define  AMA_ALLOCATE_ERROR 5 
A memory allocation error occured in a function. More...  
#define  AMA_EXTRAPOLATION 100 
Spline evaluation point requires extrapolation. More...  
Mxnind  
The following macros defines the maximum number of independent variables.  
#define  AMA_MXNIND 6 
Maximum number of independent variables. More...  
Typedefs  
typedef struct ama_options  AMA_OPTIONS 
typedef CNSPLA_SPLINE  AMA_SPLINE 
Enumerations  
enum  AMA_Boolean { AMA_Boolean_False, AMA_Boolean_True } 
This enumeration provides a boolean capability. More...  
enum  AMA_BoundaryConditions { AMA_BoundaryConditions_Default, AMA_BoundaryConditions_Natural, AMA_BoundaryConditions_Spline } 
This enumeration specifies the boundary conditions imposed by the following AMA Functions: More...  
enum  AMA_Continuity { AMA_Continuity_Full, AMA_Continuity_Reduced } 
This enumeration specifies the spline continuity condition imposed by the following AMA Functions: More...  
enum  AMA_Monotonicity { AMA_Monotonicity_Disabled, AMA_Monotonicity_Disabled_Positive, AMA_Monotonicity_Disabled_Negative, AMA_Monotonicity_Disabled_Zero, AMA_Monotonicity_Enabled } 
This enumeration specifies the monotonicity constraints imposed by the following AMA Functions: More...  
enum  AMA_ErrorFlag { AMA_ErrorFlag_Disabled, AMA_ErrorFlag_Enabled } 
This enumeration specifies if error messages are written to AMA_OPTIONS::errorFp. More...  
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...  
#define AMA_ALLOCATE_ERROR 5 
A memory allocation error occured in a function.
Execution is terminated and a traceback message is reported.
#define AMA_EXTRAPOLATION 100 
Spline evaluation point requires extrapolation.
#define AMA_FATAL_ERROR 4 
An invalid value of an input parameter defined within an AMA Function is passed to another AMA Function.
Execution is terminated and a traceback message is reported.
#define AMA_INPUT_ERROR 3 
An invalid value of an input parameter defined by the user is passed to a function.
Execution is terminated and a traceback message is not reported.
#define AMA_MXNIND 6 
Maximum number of independent variables.
#define AMA_NO_ERROR 0 
No errors occured during function execution.
#define AMA_PROCESS_ERROR 2 
A process error occured in one or more functions.
Execution is continued and a traceback message is not reported.
#define AMA_WARNING_ERROR 1 
A warning error occured in one or more functions.
Execution is continued and a traceback message is not reported.
typedef struct ama_options AMA_OPTIONS 
typedef CNSPLA_SPLINE AMA_SPLINE 
enum AMA_Boolean 
This enumeration specifies the boundary conditions imposed by the following AMA Functions:
The first five functions compute an univariate spline
based the independent variable data , for . By default the five univariate approximation and interpolation functions do not imposed boundary conditions, with the exception of AMA_UnvInterp(), which imposes natural boundary conditions. However, boundary conditions can be imposed with AMA_OptionsSetUnvBoundaryConditions(). See AMA_UnvBoundaryConditions() for additional information about the boundary conditions associated with the different values of AMA_BoundaryConditions.
The latter ten functions compute a multivariate spline
based on the independent variable data , for . With the exception of AMA_MltvInterp() and AMA_MltvGrdInterp(), which impose natural boundary conditions, these functions do not impose any boundary conditions. However, boundary conditions can be imposed with AMA_OptionsSetMltvBoundaryConditions(). See AMA_MltvBoundaryConditions() for additional information about the boundary conditions associated with the different values of AMA_BoundaryConditions.
Documented 102515
enum AMA_Continuity 
This enumeration specifies the spline continuity condition imposed by the following AMA Functions:
The first two functions compute an univariate spline
based the independent variable data , for . The knot vector is defined by AMA_LamdaMonoInterp() and it includes knots which lie at the interior data points , for , at which the spline can satisfy either the full or reduced continuity condition. The following table summarizes the continuity of the spline at interior data points for linear through quintic splines.
The following table summarizes the continuity of , for , and the number of coefficients, , for a spline that satisfies the full and reduced continuity conditions.
Degree  Full Continuity  Reduced Continuity  

Linear  is continuous for  is continuous for  
Quadratic  is continuous for  is continuous for  
Cubic  is continuous for  is continuous for  
Quartic  is continuous for  is continuous for  
Quintic  is continuous for  is continuous for 
The latter four functions compute a multivariate spline
based on the independent variable data , for . If the rectilinear grid upon which the data lies is , then the knot vectors are defined by AMA_LamdaMonoInterp() and they include knots which lie at the interior grid points , for , at which the spline can satisfy either the full or reduced continuity condition.
The following table summarizes the continuity of with respect to at the interior grid points , for , and the number of coefficients, , for a spline that satisfies either the full or reduced continuity condition. In the table the term
is the th order partial of with respect to evaluated at and defined over the region .
Degree  Full Continuity  Reduced Continuity  

Linear  is continuous for  is continuous for  
Quadratic  is continuous for  is continuous for  
Cubic  is continuous for  is continuous for  
Quartic  is continuous for  is continuous for  
Quintic  is continuous for  is continuous for 
By default the splines produced by the aforementioned functions satisfy the full continuity condition but the reduced continuity condition can be requested with AMA_OptionsSetContinuity().
Documented 102515
Enumerator  

AMA_Continuity_Full 
The spline satisfies the full continuity condition. 
AMA_Continuity_Reduced 
The spline satisfies the reduced continuity condition. 
enum AMA_ErrorFlag 
This enumeration specifies if error messages are written to AMA_OPTIONS::errorFp.
Documented 101913
Enumerator  

AMA_ErrorFlag_Disabled 
Error messages are not written to AMA_OPTIONS::errorFp. 
AMA_ErrorFlag_Enabled 
Error messages are written to AMA_OPTIONS::errorFp. 
enum AMA_Monotonicity 
This enumeration specifies the monotonicity constraints imposed by the following AMA Functions:
The first two functions compute an univariate spline
based the independent variable data , for . They impose positive derivative constraints in intervals of increasing data, negative derivative constraints in intervals of decreasing data, and zero derivative constraints in intervals of equal data. See AMA_UnvConreg() for additional details about the monotonicity constraints imposed by these two univariate functions. By default the monotonicity constraints are enabled but they can be disabled with AMA_OptionsSetMonotonicity().
The latter four functions compute a multivariate spline
based on the independent variable data , for . They impose positive partial derivative constraints in intervals of increasing data, negative partial derivative constraints in intervals of decreasing data, and partial derivative equal to zero constraints in intervals of equal data. The constraints can be imposed in , for . See AMA_MltvConreg() for additional details about the monotonicity constraints imposed by these four multivariate functions. By default the monotonicity constraints are imposed in all independent variables but they can be disabled with AMA_OptionsSetMonotonicity().
Documented 102515
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 , for , this function computes a knot vector 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 depends on the degree, , of the spline approximation. If the degree is even, then the knot vector , where , is defined such that its distinct knots are
If the degree is odd, then the knot vector , where , is defined such that its distinct knots are
Regardless of the degree its corresponding knot multiplicity vector is
options  [in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_LamdaInterp(). 
n  [in] The number of data points . Must satisfy n . 
x  [in] Array of size n containing the independent variable data , for . Must be in strictly ascending order. 
degree  [in] The degree . Must satisfy degree . 
mlamda  [out] The number of knots . Must satisfy mlamda NULL. 
lamda  [out] Pointer to an array of size mlamda containing the knot vector . Must satisfy lamda NULL. 
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 , for , this function computes a knot vector 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, , and the continuity of the spline at the interior data points , for .
If the spline is linear, , then independent of the continuity condition the spline's value is continuous at the interior data points and the knot vector is defined such that its distinct knot and knot multiplicity vectors are
and
The number of spline coefficients is . If , then the knot vector 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 and its derivatives , for , are continuous at , for . In this case the knot vector is defined such that its distinct knots are
for and ; and . For example, if the spline is quadratic, , then the distinct knot vector is
and; if if the spline is cubic, , then the distinct knot vector is
Regardless of the degree its corresponding knot multiplicity vector is
and the number of spline coefficients is . 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 , for .
If a reduced continuity condition is requested, then the knot vector depends on the spline's degree. If the spline is quadratic, , or cubic, , then the knot vector is defined such that its distinct knot and knot multiplicity vectors are
and
The number of spline coefficients is .
If , then for each interval , for , this function defines the knots
for , of multiplicity one and knots of multiplicity two at the interior data points , for , along with knots of multiplicity at the endpoints and . That is, if the spline is quartic, , then and its distinct knot and knot multiplicity vectors are
and
The number of spline coefficients is . However, if the spline is quintic, , then and its distinct knot and knot multiplicity vectors are
and
The number of spline coefficients is . 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 , for .
The following table summarizes the continuity of , for , and the number of coefficients, , for a spline that satisfies the full and reduced continuity conditions.
Degree  Full Continuity  Reduced Continuity  

Linear  is continuous for  is continuous for  
Quadratic  is continuous for  is continuous for  
Cubic  is continuous for  is continuous for  
Quartic  is continuous for  is continuous for  
Quintic  is continuous for  is continuous for 
options  [in] Pointer to AMA_OPTIONS. Must be initialized with AMA_Options() prior to calling AMA_LamdaMonoInterp(). 
n  [in] The number of data points . Must satisfy n . 
x  [in] Array of size n containing the independent variable data , for . Must be in strictly ascending order. 
degree  [in] The degree . Must satisfy degree . 
continuity  [in] Continuity condition flag. It has one of the following two values:

mlamda  [out] The number of knots . Must satisfy mlamda NULL. 
lamda  [out] Pointer to an array of size mlamda containing the knot vector . Must satisfy lamda NULL. 
User Support Function  Documented 110415  !!!THIS IS NOT A USER CALLABLE FUNCTION  DOCUMENT IS INCLUDED FOR COMPLETENESS!!!