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

# Syntax

C#
```public static void e02df(
int mx,
int my,
int px,
int py,
double[] x,
double[] y,
double[] lamda,
double[] mu,
double[] c,
double[] ff,
out int ifail
)```
Visual Basic
```Public Shared Sub e02df ( _
mx As Integer, _
my As Integer, _
px As Integer, _
py As Integer, _
x As Double(), _
y As Double(), _
lamda As Double(), _
mu As Double(), _
c As Double(), _
ff As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void e02df(
int mx,
int my,
int px,
int py,
array<double>^ x,
array<double>^ y,
array<double>^ lamda,
array<double>^ mu,
array<double>^ c,
array<double>^ ff,
[OutAttribute] int% ifail
)```
F#
```static member e02df :
mx : int *
my : int *
px : int *
py : int *
x : float[] *
y : float[] *
lamda : float[] *
mu : float[] *
c : float[] *
ff : float[] *
ifail : int byref -> unit
```

#### Parameters

mx
Type: System..::..Int32
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$.
my
Type: System..::..Int32
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$.
px
Type: System..::..Int32
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$.
py
Type: System..::..Int32
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$.
x
Type: array<System..::..Double>[]()[][]
An array of size [mx]
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[3]≤x[q-1]
and
 $mu[3]≤y[r-1]
.
The spline representation is not valid outside these intervals.
y
Type: array<System..::..Double>[]()[][]
An array of size [mx]
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[3]≤x[q-1]
and
 $mu[3]≤y[r-1]
.
The spline representation is not valid outside these intervals.
lamda
Type: array<System..::..Double>[]()[][]
An array of size [px]
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}}-4\right]>{\mathbf{lamda}}\left[3\right]$ and ${\mathbf{mu}}\left[{\mathbf{py}}-4\right]>{\mathbf{mu}}\left[3\right]$.
mu
Type: array<System..::..Double>[]()[][]
An array of size [px]
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}}-4\right]>{\mathbf{lamda}}\left[3\right]$ and ${\mathbf{mu}}\left[{\mathbf{py}}-4\right]>{\mathbf{mu}}\left[3\right]$.
c
Type: array<System..::..Double>[]()[][]
An array of size [$\left({\mathbf{px}}-4\right)×\left({\mathbf{py}}-4\right)$]
On entry: ${\mathbf{c}}\left[\left({\mathbf{py}}-4\right)×\left(\mathit{i}-1\right)+\mathit{j}-1\right]$ must contain the coefficient ${c}_{\mathit{i}\mathit{j}}$ described in [Description], for $\mathit{i}=1,2,\dots ,{\mathbf{px}}-4$ and $\mathit{j}=1,2,\dots ,{\mathbf{py}}-4$.
ff
Type: array<System..::..Double>[]()[][]
An array of size [${\mathbf{mx}}×{\mathbf{my}}$]
On exit: ${\mathbf{ff}}\left[{\mathbf{my}}×\left(\mathit{q}-1\right)+\mathit{r}-1\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}$.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

e02df 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
 $sx,y=∑ijcijMixNjy.$
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 method may be used to calculate values of a bicubic spline given in the form produced by e01da (E02DAF not in this release) (E02DCF not in this release) (E02DDF not in this release). It is derived from the method 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

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{mx}}<1$, or ${\mathbf{my}}<1$, or ${\mathbf{py}}<8$, or ${\mathbf{px}}<8$.
${\mathbf{ifail}}=2$
 On entry, lwrk is too small, or liwrk is too small.
${\mathbf{ifail}}=3$
On entry, the knots in array lamda, or those in array mu, are not in nondecreasing order, or ${\mathbf{lamda}}\left[{\mathbf{px}}-4\right]\le {\mathbf{lamda}}\left[3\right]$, or ${\mathbf{mu}}\left[{\mathbf{py}}-4\right]\le {\mathbf{mu}}\left[3\right]$.
${\mathbf{ifail}}=4$
On entry, the restriction ${\mathbf{lamda}}\left[3\right]\le {\mathbf{x}}\left[0\right]<\cdots <{\mathbf{x}}\left[{\mathbf{mx}}-1\right]\le {\mathbf{lamda}}\left[{\mathbf{px}}-4\right]$, or the restriction ${\mathbf{mu}}\left[3\right]\le {\mathbf{y}}\left[0\right]<\cdots <{\mathbf{y}}\left[{\mathbf{my}}-1\right]\le {\mathbf{mu}}\left[{\mathbf{py}}-4\right]$, is violated.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

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.

# Parallelism and Performance

None.

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

# Example

This example reads in knot sets ${\mathbf{lamda}}\left[0\right],\dots ,{\mathbf{lamda}}\left[{\mathbf{px}}-1\right]$ and ${\mathbf{mu}}\left[0\right],\dots ,{\mathbf{mu}}\left[{\mathbf{py}}-1\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.

Example program (C#): e02dfe.cs

Example program data: e02dfe.d

Example program results: e02dfe.r