nag_2d_spline_eval_rect (e02dfc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_2d_spline_eval_rect (e02dfc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

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

3  Description

nag_2d_spline_eval_rect (e02dfc) calculates values of the bicubic spline s x,y  on a rectangular grid of points in the x - y  plane, 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 .
The points in the grid are defined by coordinates x q , for q=1,2,, m x , along the x  axis, and coordinates y r , for r=1,2,, m y  along the y  axis.
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:     mxIntegerInput
2:     myIntegerInput
On entry: mx and my must specify m x  and m y  respectively, the number of points along the x  and y  axes that define the rectangular grid.
Constraint: mx1  and my1 .
3:     x[mx]const doubleInput
4:     y[my]const doubleInput
On entry: x and y must contain x q , for q=1,2,, m x , and y r , for r=1,2,, 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: x and y must satisfy splinelamda[3] x[q-1] < x[q] splinelamda[splinenx-4] , for q=1,2,, m x - 1, and splinemu[3] y[r-1] < y[r] splinemu[splineny-4] , for r=1,2,, m y - 1.
The spline representation is not valid outside these intervals.
5:     ff[mx×my]doubleOutput
On exit: ff[ my × q-1 + r - 1 ]  contains the value of the spline at the point x q , y r , for q=1,2,, m x  and r=1,2,, m y .
6:     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 variable x . It is such that nx-8  is the number of interior knots.
Constraint: nx8 .
lamdadoubleInput
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 non-decreasing 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 .
mudoubleInput
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 non-decreasing order, with mu[ny-4] > mu[3] .
cdoubleInput
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_rect (e02dfc) 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_rect (e02dfc).
7:     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, mx=value.
Constraint: mx1.
On entry, my=value.
Constraint: my1.
On entry, splinenx must not be less than 8: splinenx=value .
On entry, splineny must not be less than 8: splineny=value .
NE_KNOTS_COORD_CONS
On entry, the end knots and coordinates must satisfy splinelamda[3] x[0]  and x[mx-1] splinelamda[splinenx-4] . splinelamda[3] = value, x[0] = value, x[value] = value, splinelamda[value] = value.
On entry, the end knots and coordinates must satisfy splinemu[3] y[0]  and y[my-1] splinemu[splineny-4] . splinemu[3] = value, y[0] = value, y[value] = value, splinemu[value] = 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_NOT_STRICTLY_INCREASING
The sequence x is not strictly increasing: x[value] = value, x[value] = value.
The sequence y is not strictly increasing: y[value] = value, y[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  Further Comments

Computation time is approximately proportional to m x m y + 4 m x + m y .

9  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 values for m x  and the x  coordinates x q , for q=1,2,, m x , and values for m y  and the y  coordinates y r , for r=1,2,, m y , defining the grid of points on which the spline is to be evaluated.

9.1  Program Text

Program Text (e02dfce.c)

9.2  Program Data

Program Data (e02dfce.d)

9.3  Program Results

Program Results (e02dfce.r)


nag_2d_spline_eval_rect (e02dfc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG C Library Manual

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