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,…,spline→nx - 4 and j=1,2,…,spline→ny - 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:     m – IntegerInput
On entry: m , the number of points at which values of the spline are required.
Constraint: m≥1 .
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
spline→lamda[3] ≤ x[r-1] ≤ spline→lamda[spline→nx-4]
and
spline→mu[3] ≤ y[r-1] ≤ spline→mu[spline→ny-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:     spline – Nag_2dSpline *
Pointer to structure of type Nag_2dSpline with the following members:
nx – IntegerInput
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: nx≥8 .
lamda – double *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] .
ny – IntegerInput
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: ny≥8 .
mu – double *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] .
c – double *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:     fail – NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

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: m≥1.
On entry, spline→nx must not be less than 8: spline→nx=value .
On entry, spline→ny must not be less than 8: spline→ny=value .
NE_NOT_INCREASING
The sequence spline→lamda is not increasing: spline→lamda[value] = value, spline→lamda[value] = value.
The sequence spline→mu is not increasing: spline→mu[value] = value, spline→mu[value] = value.
NE_POINT_OUTSIDE_RECT
On entry, point x[value] = value , y[value] = value  lies outside the rectangle bounded by spline→lamda[3] = value, spline→lamda[value] = value, spline→mu[3] = value, spline→mu[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

nag_2d_spline_eval (e02dec) 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 spline→lamda[0] , … , spline→lamda[spline→nx-1]  and spline→mu[0] , … , spline→mu[spline→ny-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)

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