# NAG FL Interfacee02dff (dim2_​spline_​evalm)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e02dff calculates values of a bicubic spline from its B-spline representation. The spline is evaluated at all points on a rectangular grid.

## 2Specification

Fortran Interface
 Subroutine e02dff ( mx, my, px, py, x, y, mu, c, ff, wrk, lwrk, iwrk,
 Integer, Intent (In) :: mx, my, px, py, lwrk, liwrk Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: iwrk(liwrk) Real (Kind=nag_wp), Intent (In) :: x(mx), y(my), lamda(px), mu(py), c((px-4)*(py-4)) Real (Kind=nag_wp), Intent (Out) :: ff(mx*my), wrk(lwrk)
#include <nag.h>
 void e02dff_ (const Integer *mx, const Integer *my, const Integer *px, const Integer *py, const double x[], const double y[], const double lamda[], const double mu[], const double c[], double ff[], double wrk[], const Integer *lwrk, Integer iwrk[], const Integer *liwrk, Integer *ifail)
The routine may be called by the names e02dff or nagf_fit_dim2_spline_evalm.

## 3Description

e02dff calculates values of the bicubic spline $s\left(x,y\right)$ on a rectangular grid of points in the $x$-$y$ plane, from its augmented knot sets $\left\{\lambda \right\}$ and $\left\{\mu \right\}$ and from the coefficients ${c}_{ij}$, for $\mathit{i}=1,2,\dots ,{\mathbf{px}}-4$ and $\mathit{j}=1,2,\dots ,{\mathbf{py}}-4$, in its B-spline representation
 $s(x,y) = ∑ij cij Mi(x) Nj(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}$.
The points in the grid are defined by coordinates ${x}_{q}$, for $\mathit{q}=1,2,\dots ,{m}_{x}$, along the $x$ axis, and coordinates ${y}_{r}$, for $\mathit{r}=1,2,\dots ,{m}_{y}$, along the $y$ axis.
This routine may be used to calculate values of a bicubic spline given in the form produced by e01daf, e02daf, e02dcf and e02ddf. It is derived from the routine B2VRE in Anthony et al. (1982).

## 4References

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{mx}$Integer Input
2: $\mathbf{my}$Integer Input
On entry: mx and my must specify ${m}_{x}$ and ${m}_{y}$ respectively, the number of points along the $x$ and $y$ axis that define the rectangular grid.
Constraint: ${\mathbf{mx}}\ge 1$ and ${\mathbf{my}}\ge 1$.
3: $\mathbf{px}$Integer Input
4: $\mathbf{py}$Integer Input
On entry: px and py must specify the total number of knots associated with the variables $x$ and $y$ respectively. They are such that ${\mathbf{px}}-8$ and ${\mathbf{py}}-8$ are the corresponding numbers of interior knots.
Constraint: ${\mathbf{px}}\ge 8$ and ${\mathbf{py}}\ge 8$.
5: $\mathbf{x}\left({\mathbf{mx}}\right)$Real (Kind=nag_wp) array Input
6: $\mathbf{y}\left({\mathbf{my}}\right)$Real (Kind=nag_wp) array Input
On entry: x and y must contain ${x}_{\mathit{q}}$, for $\mathit{q}=1,2,\dots ,{m}_{x}$, and ${y}_{\mathit{r}}$, for $\mathit{r}=1,2,\dots ,{m}_{y}$, respectively. These are the $x$ and $y$ coordinates that define the rectangular grid of points at which values of the spline are required.
Constraint: ${\mathbf{x}}$ and y must satisfy
 $lamda(4) ≤ x(q) < x(q+1) ≤ lamda(px-3) , q=1,2,…,mx-1$
and
 $mu(4) ≤ y(r) < y(r+1) ≤ mu(py-3) , r= 1,2,…,my- 1 .$
.
The spline representation is not valid outside these intervals.
7: $\mathbf{lamda}\left({\mathbf{px}}\right)$Real (Kind=nag_wp) array Input
8: $\mathbf{mu}\left({\mathbf{py}}\right)$Real (Kind=nag_wp) array Input
On entry: lamda and mu must contain the complete sets of knots $\left\{\lambda \right\}$ and $\left\{\mu \right\}$ associated with the $x$ and $y$ variables respectively.
Constraint: the knots in each set must be in nondecreasing order, with ${\mathbf{lamda}}\left({\mathbf{px}}-3\right)>{\mathbf{lamda}}\left(4\right)$ and ${\mathbf{mu}}\left({\mathbf{py}}-3\right)>{\mathbf{mu}}\left(4\right)$.
9: $\mathbf{c}\left(\left({\mathbf{px}}-4\right)×\left({\mathbf{py}}-4\right)\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{c}}\left(\left({\mathbf{py}}-4\right)×\left(\mathit{i}-1\right)+\mathit{j}\right)$ must contain the coefficient ${c}_{\mathit{i}\mathit{j}}$ described in Section 3, for $\mathit{i}=1,2,\dots ,{\mathbf{px}}-4$ and $\mathit{j}=1,2,\dots ,{\mathbf{py}}-4$.
10: $\mathbf{ff}\left({\mathbf{mx}}×{\mathbf{my}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{ff}}\left({\mathbf{my}}×\left(\mathit{q}-1\right)+\mathit{r}\right)$ contains the value of the spline at the point $\left({x}_{\mathit{q}},{y}_{\mathit{r}}\right)$, for $\mathit{q}=1,2,\dots ,{m}_{x}$ and $\mathit{r}=1,2,\dots ,{m}_{y}$.
11: $\mathbf{wrk}\left({\mathbf{lwrk}}\right)$Real (Kind=nag_wp) array Workspace
12: $\mathbf{lwrk}$Integer Input
On entry: the dimension of the array wrk as declared in the (sub)program from which e02dff is called.
Constraint: ${\mathbf{lwrk}}\ge \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(4×{\mathbf{mx}}+{\mathbf{px}},4×{\mathbf{my}}+{\mathbf{py}}\right)$.
13: $\mathbf{iwrk}\left({\mathbf{liwrk}}\right)$Integer array Workspace
14: $\mathbf{liwrk}$Integer Input
On entry: the dimension of the array iwrk as declared in the (sub)program from which e02dff is called.
Constraints:
• if $4×{\mathbf{mx}}+{\mathbf{px}}>4×{\mathbf{my}}+{\mathbf{py}}$, ${\mathbf{liwrk}}\ge {\mathbf{my}}+{\mathbf{py}}-4$;
• otherwise ${\mathbf{liwrk}}\ge {\mathbf{mx}}+{\mathbf{px}}-4$.
15: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{mx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mx}}\ge 1$.
On entry, ${\mathbf{my}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{my}}\ge 1$.
On entry, ${\mathbf{px}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{px}}\ge 8$.
On entry, ${\mathbf{py}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{py}}\ge 8$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{liwrk}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{liwrk}}\ge ⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{lwrk}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lwrk}}\ge ⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=3$
On entry, the knots in lamda are not in nondecreasing order.
On entry, the knots in mu are not in nondecreasing order.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{lamda}}\left(4\right)\le {\mathbf{x}}\left(1\right)<\cdots <{\mathbf{x}}\left({\mathbf{mx}}\right)\le {\mathbf{lamda}}\left({\mathbf{px}}-3\right)$ is violated.
On entry, ${\mathbf{mu}}\left(4\right)\le {\mathbf{y}}\left(1\right)<\cdots <{\mathbf{y}}\left({\mathbf{my}}\right)\le {\mathbf{mu}}\left({\mathbf{py}}-3\right)$ is violated.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 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

e02dff is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Computation time is approximately proportional to ${m}_{x}{m}_{y}+4\left({m}_{x}+{m}_{y}\right)$.

## 10Example

This example reads in knot sets ${\mathbf{lamda}}\left(1\right),\dots ,{\mathbf{lamda}}\left({\mathbf{px}}\right)$ and ${\mathbf{mu}}\left(1\right),\dots ,{\mathbf{mu}}\left({\mathbf{py}}\right)$, and a set of bicubic spline coefficients ${c}_{ij}$. Following these are values for ${m}_{x}$ and the $x$ coordinates ${x}_{q}$, for $\mathit{q}=1,2,\dots ,{m}_{x}$, and values for ${m}_{y}$ and the $y$ coordinates ${y}_{r}$, for $\mathit{r}=1,2,\dots ,{m}_{y}$, defining the grid of points on which the spline is to be evaluated.

### 10.1Program Text

Program Text (e02dffe.f90)

### 10.2Program Data

Program Data (e02dffe.d)

### 10.3Program Results

Program Results (e02dffe.r)