NAG FL Interface
e02def (dim2_​spline_​evalv)

1 Purpose

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

2 Specification

Fortran Interface
Subroutine e02def ( m, px, py, x, y, lamda, mu, c, ff, wrk, iwrk, ifail)
Integer, Intent (In) :: m, px, py
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: iwrk(py-4)
Real (Kind=nag_wp), Intent (In) :: x(m), y(m), lamda(px), mu(py), c((px-4)*(py-4))
Real (Kind=nag_wp), Intent (Out) :: ff(m), wrk(py-4)
C Header Interface
#include <nag.h>
void  e02def_ (const Integer *m, 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[], Integer iwrk[], Integer *ifail)
The routine may be called by the names e02def or nagf_fit_dim2_spline_evalv.

3 Description

e02def calculates values of the bicubic spline sx,y at prescribed points xr,yr, for r=1,2,,m, from its augmented knot sets λ and μ and from the coefficients cij, for i=1,2,,px-4 and j=1,2,,py-4, in its B-spline representation
sx,y=ijcijMixNjy.  
Here Mix and Njy denote normalized cubic B-splines, the former defined on the knots λi to λi+4 and the latter on the knots μj to μj+4.
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).

4 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

5 Arguments

1: m Integer Input
On entry: m, the number of points at which values of the spline are required.
Constraint: m1.
2: px Integer Input
3: 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 px-8 and py-8 are the corresponding numbers of interior knots.
Constraint: px8 and py8.
4: xm Real (Kind=nag_wp) array Input
5: ym Real (Kind=nag_wp) array Input
On entry: x and y must contain xr and yr, for r=1,2,,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
lamda4xrlamdapx-3  
and
mu4yrmupy- 3,   r= 1,2,,m. 
The spline representation is not valid outside these intervals
6: lamdapx Real (Kind=nag_wp) array Input
7: mupy Real (Kind=nag_wp) array Input
On entry: lamda and mu must contain the complete sets of knots λ and μ associated with the x and y variables respectively.
Constraint: the knots in each set must be in nondecreasing order, with lamdapx-3>lamda4 and mupy-3>mu4.
8: cpx-4×py-4 Real (Kind=nag_wp) array Input
On entry: c py-4 × i-1 +j must contain the coefficient cij described in Section 3, for i=1,2,,px-4 and j=1,2,,py-4.
9: ffm Real (Kind=nag_wp) array Output
On exit: ffr contains the value of the spline at the point xr,yr, for r=1,2,,m.
10: wrkpy-4 Real (Kind=nag_wp) array Workspace
11: iwrkpy-4 Integer array Workspace
12: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry 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:
ifail=1
On entry, m=value.
Constraint: m1.
On entry, px=value.
Constraint: px8.
On entry, py=value.
Constraint: py8.
ifail=2
On entry, the knots in lamda are not in nondecreasing order.
On entry, the knots in mu are not in nondecreasing order.
ifail=3
On entry, point xK,yK lies outside the rectangle bounded by lamda4, lamdapx-3, mu4, mupy-3: K=value, xK=value and yK=value.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

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

8 Parallelism and Performance

e02def is not threaded in any implementation.

9 Further Comments

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

10 Example

This program reads in knot sets lamda1,,lamdapx and mu1,,mupy, and a set of bicubic spline coefficients cij. Following these are a value for m and the coordinates xr,yr, for r=1,2,,m, at which the spline is to be evaluated.

10.1 Program Text

Program Text (e02defe.f90)

10.2 Program Data

Program Data (e02defe.d)

10.3 Program Results

Program Results (e02defe.r)
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1 1.5 2 2.5 3 3.5 4 4.5 5 Example Program Evaluation of Least-squares Bicubic Spline Fit at Scattered Points gnuplot_plot_1 Evaluatuation points gnuplot_plot_2 gnuplot_plot_3 Bicubic Spline Surface x y