nag_2d_spline_eval (e02dec) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_2d_spline_eval (e02dec)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

#include <nag.h>
#include <nage02.h>
void  nag_2d_spline_eval (Integer m, const double x[], const double y[], double ff[], Nag_2dSpline *spline, NagError *fail)

3  Description

nag_2d_spline_eval (e02dec) calculates values of the bicubic spline s x,y  at prescribed points x r , y r , for r=1,2,,m, from its augmented knot sets λ  and μ  and from the coefficients c ij , for i=1,2,,splinenx - 4 and j=1,2,,splineny - 4, in its B-spline representation
s x,y = i,j c ij M i x N j y .
Here M i x  and N j y  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 function may be used to calculate values of a bicubic spline given in the form produced by nag_2d_spline_interpolant (e01dac), nag_2d_spline_fit_grid (e02dcc) and nag_2d_spline_fit_scat (e02ddc). 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:     mIntegerInput
On entry: m , the number of points at which values of the spline are required.
Constraint: m1 .
2:     x[m]const doubleInput
3:     y[m]const doubleInput
On entry: x and y must contain x r  and y r , 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
splinelamda[3] x[r-1] splinelamda[splinenx-4]
and
splinemu[3] y[r-1] splinemu[splineny-4] .
The spline representation is not valid outside these intervals, for r=1,2,,m.
4:     ff[m]doubleOutput
On exit: ff[r-1]  contains the value of the spline at the point x r , y r , for r=1,2,,m.
5:     splineNag_2dSpline *
Pointer to structure of type Nag_2dSpline with the following members:
nxIntegerInput
On entry: nx must specify the total number of knots associated with the variables x . It is such that nx-8  is the number of interior knots.
Constraint: nx8 .
lamdadouble *Input
On entry: a pointer to which memory of size nx must be allocated. lamda must contain the complete sets of knots λ  associated with the x  variable.
Constraint: the knots must be in nondecreasing order, with lamda[nx-4] > lamda[3] .
nyIntegerInput
On entry: ny must specify the total number of knots associated with the variable y .
It is such that ny-8  is the number of interior knots.
Constraint: ny8 .
mudouble *Input
On entry: a pointer to which memory of size ny must be allocated. mu must contain the complete sets of knots μ  associated with the y  variable.
Constraint: the knots must be in nondecreasing order, with mu[ny-4] > mu[3] .
cdouble *Input
On entry: a pointer to which memory of size nx-4 × ny-4  must be allocated. c[ ny-4 × i-1 + j - 1 ]  must contain the coefficient c ij  described in Section 3, for i=1,2,,nx - 4 and j=1,2,,ny - 4.
In normal usage, the call to nag_2d_spline_eval (e02dec) follows a call to nag_2d_spline_interpolant (e01dac), nag_2d_spline_fit_grid (e02dcc) or nag_2d_spline_fit_scat (e02ddc), in which case, members of the structure spline will have been set up correctly for input to nag_2d_spline_eval (e02dec).
6:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_END_KNOTS_CONS
On entry, the end knots must satisfy value, value=value , value=value .
NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, splinenx must not be less than 8: splinenx=value .
On entry, splineny must not be less than 8: splineny=value .
NE_NOT_INCREASING
The sequence splinelamda is not increasing: splinelamda[value] = value, splinelamda[value] = value.
The sequence splinemu is not increasing: splinemu[value] = value, splinemu[value] = value.
NE_POINT_OUTSIDE_RECT
On entry, point x[value] = value , y[value] = value  lies outside the rectangle bounded by splinelamda[3] = value, splinelamda[value] = value, splinemu[3] = value, splinemu[value] = value.

7  Accuracy

The method used to evaluate the B-splines is numerically stable, in the sense that each computed value of s x r , y r  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

Not applicable.

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 splinelamda[0] , , splinelamda[splinenx-1]  and splinemu[0] , , splinemu[splineny-1] , and a set of bicubic spline coefficients c ij . Following these are a value for m  and the coordinates x r , y r , for r=1,2,,m, at which the spline is to be evaluated.

10.1  Program Text

Program Text (e02dece.c)

10.2  Program Data

Program Data (e02dece.d)

10.3  Program Results

Program Results (e02dece.r)


nag_2d_spline_eval (e02dec) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014