Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_2dspline_evalv (e02de)

Purpose

nag_fit_2dspline_evalv (e02de) calculates values of a bicubic spline from its B-spline representation.

Syntax

[ff, ifail] = e02de(x, y, lamda, mu, c, 'm', m, 'px', px, 'py', py)
[ff, ifail] = nag_fit_2dspline_evalv(x, y, lamda, mu, c, 'm', m, 'px', px, 'py', py)

Description

nag_fit_2dspline_evalv (e02de) calculates values of the bicubic spline s(x,y)$s\left(x,y\right)$ at prescribed points (xr,yr)$\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,m$, from its augmented knot sets {λ}$\left\{\lambda \right\}$ and {μ}$\left\{\mu \right\}$ and from the coefficients cij${c}_{ij}$, for i = 1,2,,px4$\mathit{i}=1,2,\dots ,{\mathbf{px}}-4$ and j = 1,2,,py4$\mathit{j}=1,2,\dots ,{\mathbf{py}}-4$, in its B-spline representation
 s(x,y) = ∑ cijMi(x)Nj(y). ij
$s(x,y)=∑ijcijMi(x)Nj(y).$
Here Mi(x)${M}_{i}\left(x\right)$ and Nj(y)${N}_{j}\left(y\right)$ denote normalized cubic B-splines, the former defined on the knots λi${\lambda }_{i}$ to λi + 4${\lambda }_{i+4}$ and the latter on the knots μj${\mu }_{j}$ to μj + 4${\mu }_{j+4}$.
This function may be used to calculate values of a bicubic spline given in the form produced by nag_interp_2d_spline_grid (e01da), nag_fit_2dspline_panel (e02da), nag_fit_2dspline_grid (e02dc) and nag_fit_2dspline_sctr (e02dd). It is derived from the function B2VRE in Anthony et al. (1982).

References

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

Parameters

Compulsory Input Parameters

1:     x(m) – double array
2:     y(m) – double array
m, the dimension of the array, must satisfy the constraint m1${\mathbf{m}}\ge 1$.
x and y must contain xr${x}_{\mathit{r}}$ and yr${y}_{\mathit{r}}$, for r = 1,2,,m$\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${\mathbf{x}}$ and y${\mathbf{y}}$ must satisfy
 lamda(4) ≤ x(r) ≤ lamda(px − 3) $lamda4≤xr≤lamdapx-3$
and
 mu(4) ≤ y(r) ≤ mu(py − 3),   r = 1,2, … ,m. $mu4≤yr≤mupy- 3, r= 1,2,…,m.$
.
The spline representation is not valid outside these intervals.
3:     lamda(px) – double array
4:     mu(py) – double array
px, the dimension of the array, must satisfy the constraint px8${\mathbf{px}}\ge 8$ and py8${\mathbf{py}}\ge 8$.
lamda and mu must contain the complete sets of knots {λ}$\left\{\lambda \right\}$ and {μ}$\left\{\mu \right\}$ associated with the x$x$ and y$y$ variables respectively.
Constraint: the knots in each set must be in nondecreasing order, with lamda(px3) > lamda(4)${\mathbf{lamda}}\left({\mathbf{px}}-3\right)>{\mathbf{lamda}}\left(4\right)$ and mu(py3) > mu(4)${\mathbf{mu}}\left({\mathbf{py}}-3\right)>{\mathbf{mu}}\left(4\right)$.
5:     c((px4) × (py4)$\left({\mathbf{px}}-4\right)×\left({\mathbf{py}}-4\right)$) – double array
c((py4) × (i1) + j)${\mathbf{c}}\left(\left({\mathbf{py}}-4\right)×\left(\mathit{i}-1\right)+\mathit{j}\right)$ must contain the coefficient cij${c}_{\mathit{i}\mathit{j}}$ described in Section [Description], for i = 1,2,,px4$\mathit{i}=1,2,\dots ,{\mathbf{px}}-4$ and j = 1,2,,py4$\mathit{j}=1,2,\dots ,{\mathbf{py}}-4$.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
m$m$, the number of points at which values of the spline are required.
Constraint: m1${\mathbf{m}}\ge 1$.
2:     px – int64int32nag_int scalar
3:     py – int64int32nag_int scalar
Default: For px, the dimension of the array lamda. For py, the dimension of the array mu.
px and py must specify the total number of knots associated with the variables x$x$ and y$y$ respectively. They are such that px8${\mathbf{px}}-8$ and py8${\mathbf{py}}-8$ are the corresponding numbers of interior knots.
Constraint: px8${\mathbf{px}}\ge 8$ and py8${\mathbf{py}}\ge 8$.

wrk iwrk

Output Parameters

1:     ff(m) – double array
ff(r)${\mathbf{ff}}\left(\mathit{r}\right)$ contains the value of the spline at the point (xr,yr)$\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,m$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, m < 1${\mathbf{m}}<1$, or py < 8${\mathbf{py}}<8$, or px < 8${\mathbf{px}}<8$.
ifail = 2${\mathbf{ifail}}=2$
On entry, the knots in array lamda, or those in array mu, are not in nondecreasing order, or lamda(px3)lamda(4)${\mathbf{lamda}}\left({\mathbf{px}}-3\right)\le {\mathbf{lamda}}\left(4\right)$, or mu(py3)mu(4)${\mathbf{mu}}\left({\mathbf{py}}-3\right)\le {\mathbf{mu}}\left(4\right)$.
ifail = 3${\mathbf{ifail}}=3$
On entry, at least one of the prescribed points (xr,yr)$\left({x}_{r},{y}_{r}\right)$ lies outside the rectangle defined by lamda(4)${\mathbf{lamda}}\left(4\right)$, lamda(px3)${\mathbf{lamda}}\left({\mathbf{px}}-3\right)$ and mu(4)${\mathbf{mu}}\left(4\right)$, mu(py3)${\mathbf{mu}}\left({\mathbf{py}}-3\right)$.

Accuracy

The method used to evaluate the B-splines is numerically stable, in the sense that each computed value of s(xr,yr)$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.

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

Example

```function nag_fit_2dspline_evalv_example
x = [1;
1.1;
1.5;
1.6;
1.9;
1.9;
2];
y = [0;
0.1;
0.7;
0.4;
0.3;
0.8;
1];
lamda = [1;
1;
1;
1;
1.3;
1.5;
1.6;
2;
2;
2;
2];
mu = [0;
0;
0;
0;
0.4;
0.7;
1;
1;
1;
1];
c = [1;
1.1333;
1.3667;
1.7;
1.9;
2;
1.2;
1.3333;
1.5667;
1.9;
2.1;
2.2;
1.5833;
1.7167;
1.95;
2.2833;
2.4833;
2.5833;
2.1433;
2.2767;
2.51;
2.8433;
3.0433;
3.1433;
2.8667;
3;
3.2333;
3.5667;
3.7667;
3.8667;
3.4667;
3.6;
3.8333;
4.1667;
4.3667;
4.4667;
4;
4.1333;
4.3667;
4.7;
4.9;
5];
[ff, ifail] = nag_fit_2dspline_evalv(x, y, lamda, mu, c)
```
```

ff =

1.0000
1.3100
2.9500
2.9600
3.9100
4.4100
5.0000

ifail =

0

```
```function e02de_example
x = [1;
1.1;
1.5;
1.6;
1.9;
1.9;
2];
y = [0;
0.1;
0.7;
0.4;
0.3;
0.8;
1];
lamda = [1;
1;
1;
1;
1.3;
1.5;
1.6;
2;
2;
2;
2];
mu = [0;
0;
0;
0;
0.4;
0.7;
1;
1;
1;
1];
c = [1;
1.1333;
1.3667;
1.7;
1.9;
2;
1.2;
1.3333;
1.5667;
1.9;
2.1;
2.2;
1.5833;
1.7167;
1.95;
2.2833;
2.4833;
2.5833;
2.1433;
2.2767;
2.51;
2.8433;
3.0433;
3.1433;
2.8667;
3;
3.2333;
3.5667;
3.7667;
3.8667;
3.4667;
3.6;
3.8333;
4.1667;
4.3667;
4.4667;
4;
4.1333;
4.3667;
4.7;
4.9;
5];
[ff, ifail] = e02de(x, y, lamda, mu, c)
```
```

ff =

1.0000
1.3100
2.9500
2.9600
3.9100
4.4100
5.0000

ifail =

0

```