# NAG CL Interfacee02dec (dim2_​spline_​evalv)

Settings help

CL Name Style:

## 1Purpose

e02dec calculates values of a bicubic spline from its B-spline representation.

## 2Specification

 #include
 void e02dec (Integer m, const double x[], const double y[], double ff[], Nag_2dSpline *spline, NagError *fail)
The function may be called by the names: e02dec, nag_fit_dim2_spline_evalv or nag_2d_spline_eval.

## 3Description

e02dec calculates values of the bicubic spline $s\left(x,y\right)$ at prescribed points $\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$, from its augmented knot sets $\left\{\lambda \right\}$ and $\left\{\mu \right\}$ and from the coefficients ${c}_{\mathit{i}\mathit{j}}$, for $\mathit{i}=1,2,\dots ,\mathbf{spline}\mathbf{\to }\mathbf{nx}-4$ and $\mathit{j}=1,2,\dots ,\mathbf{spline}\mathbf{\to }\mathbf{ny}-4$, in its B-spline representation
 $s (x,y) = ∑ i,j c ij M i (x) N j (y) .$
Here ${M}_{i}\left(x\right)$ and ${N}_{j}\left(y\right)$ denote normalized cubic B-splines, the former defined on the knots ${\lambda }_{i}$ to ${\lambda }_{i+4}$ and the latter on the knots ${\mu }_{j}$ to ${\mu }_{j+4}$.
This function may be used to calculate values of a bicubic spline given in the form produced by e01dac, e02dcc and e02ddc. It is derived from the routine B2VRE in Anthony et al. (1982).
Anthony G T, Cox M G and Hayes J G (1982) DASL – Data Approximation Subroutine Library National Physical Laboratory
Cox M G (1978) The numerical evaluation of a spline from its B-spline representation J. Inst. Math. Appl. 21 135–143

## 5Arguments

1: $\mathbf{m}$Integer Input
On entry: $m$, the number of points at which values of the spline are required.
Constraint: ${\mathbf{m}}\ge 1$.
2: $\mathbf{x}\left[{\mathbf{m}}\right]$const double Input
3: $\mathbf{y}\left[{\mathbf{m}}\right]$const double Input
On entry: x and y must contain ${x}_{\mathit{r}}$ and ${y}_{\mathit{r}}$, for $\mathit{r}=1,2,\dots ,m$, respectively. These are the coordinates of the points at which values of the spline are required. The order of the points is immaterial.
Constraint: x and y must satisfy
$\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[3\right]\le {\mathbf{x}}\left[\mathit{r}-1\right]\le \mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{nx}-4\right]$
and
$\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[3\right]\le {\mathbf{y}}\left[\mathit{r}-1\right]\le \mathbf{spline}\mathbf{\to }\mathbf{mu}\left[\mathbf{spline}\mathbf{\to }\mathbf{ny}-4\right]$.
The spline representation is not valid outside these intervals, for $\mathit{r}=1,2,\dots ,m$.
4: $\mathbf{ff}\left[{\mathbf{m}}\right]$double Output
On exit: ${\mathbf{ff}}\left[\mathit{r}-1\right]$ contains the value of the spline at the point $\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$.
5: $\mathbf{spline}$Nag_2dSpline *
Pointer to structure of type Nag_2dSpline with the following members:
nxIntegerInput
On entry: $\mathbf{nx}$ must specify the total number of knots associated with the variables $x$. It is such that $\mathbf{nx}-8$ is the number of interior knots.
Constraint: $\mathbf{nx}\ge 8$.
On entry: a pointer to which memory of size $\mathbf{nx}$ must be allocated. $\mathbf{lamda}$ must contain the complete sets of knots $\left\{\lambda \right\}$ associated with the $x$ variable.
Constraint: the knots must be in nondecreasing order, with $\mathbf{lamda}\left[\mathbf{nx}-4\right]>\mathbf{lamda}\left[3\right]$.
nyIntegerInput
On entry: $\mathbf{ny}$ must specify the total number of knots associated with the variable $y$.
It is such that $\mathbf{ny}-8$ is the number of interior knots.
Constraint: $\mathbf{ny}\ge 8$.
mudouble *Input
On entry: a pointer to which memory of size $\mathbf{ny}$ must be allocated. $\mathbf{mu}$ must contain the complete sets of knots $\left\{\mu \right\}$ associated with the $y$ variable.
Constraint: the knots must be in nondecreasing order, with $\mathbf{mu}\left[\mathbf{ny}-4\right]>\mathbf{mu}\left[3\right]$.
cdouble *Input
On entry: a pointer to which memory of size $\left(\mathbf{nx}-4\right)×\left(\mathbf{ny}-4\right)$ must be allocated. $\mathbf{c}\left[\left(\mathbf{ny}-4\right)×\left(\mathit{i}-1\right)+\mathit{j}-1\right]$ must contain the coefficient ${c}_{\mathit{i}\mathit{j}}$ described in Section 3, for $\mathit{i}=1,2,\dots ,\mathbf{nx}-4$ and $\mathit{j}=1,2,\dots ,\mathbf{ny}-4$.
In normal usage, the call to e02dec follows a call to e01dac, e02dcc or e02ddc, in which case, members of the structure spline will have been set up correctly for input to e02dec.
6: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_END_KNOTS_CONS
On entry, the end knots must satisfy $⟨\mathit{\text{value}}⟩$, $⟨\mathit{\text{value}}⟩=⟨\mathit{\text{value}}⟩$, $⟨\mathit{\text{value}}⟩=⟨\mathit{\text{value}}⟩$.
NE_INT_ARG_LT
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 1$.
On entry, $\mathbf{spline}\mathbf{\to }\mathbf{nx}$ must not be less than 8: $\mathbf{spline}\mathbf{\to }\mathbf{nx}=⟨\mathit{\text{value}}⟩$.
On entry, $\mathbf{spline}\mathbf{\to }\mathbf{ny}$ must not be less than 8: $\mathbf{spline}\mathbf{\to }\mathbf{ny}=⟨\mathit{\text{value}}⟩$.
NE_NOT_INCREASING
The sequence $\mathbf{spline}\mathbf{\to }\mathbf{lamda}$ is not increasing: $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$, $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
The sequence $\mathbf{spline}\mathbf{\to }\mathbf{mu}$ is not increasing: $\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$, $\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
NE_POINT_OUTSIDE_RECT
On entry, point $\left({\mathbf{x}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩,{\mathbf{y}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩\right)$ lies outside the rectangle bounded by $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[3\right]=⟨\mathit{\text{value}}⟩$, $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$, $\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[3\right]=⟨\mathit{\text{value}}⟩$, $\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.

## 7Accuracy

The method used to evaluate the B-splines is numerically stable, in the sense that each computed value of $s\left({x}_{r},{y}_{r}\right)$ can be regarded as the value that would have been obtained in exact arithmetic from slightly perturbed B-spline coefficients. See Cox (1978) for details.

## 8Parallelism and Performance

e02dec is not threaded in any implementation.

Computation time is approximately proportional to the number of points, $m$, at which the evaluation is required.

## 10Example

This program reads in knot sets $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[0\right],\dots ,\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{nx}-1\right]$ and $\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[0\right],\dots ,\mathbf{spline}\mathbf{\to }\mathbf{mu}\left[\mathbf{spline}\mathbf{\to }\mathbf{ny}-1\right]$, and a set of bicubic spline coefficients ${c}_{ij}$. Following these are a value for $m$ and the coordinates $\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$, at which the spline is to be evaluated.

### 10.1Program Text

Program Text (e02dece.c)

### 10.2Program Data

Program Data (e02dece.d)

### 10.3Program Results

Program Results (e02dece.r)