nag_2d_spline_deriv_rect (e02dhc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_2d_spline_deriv_rect (e02dhc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_2d_spline_deriv_rect (e02dhc) computes the partial derivative (of order νx, νy), of a bicubic spline approximation to a set of data values, from its B-spline representation, at points on a rectangular grid in the x-y plane. This function may be used to calculate derivatives of a bicubic spline given in the form produced by nag_2d_spline_interpolant (e01dac)nag_2d_spline_fit_panel (e02dac)nag_2d_spline_fit_grid (e02dcc) and nag_2d_spline_fit_scat (e02ddc).

2  Specification

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

3  Description

nag_2d_spline_deriv_rect (e02dhc) determines the partial derivative νx + νy x νx y νy  of a smooth bicubic spline approximation sx,y at the set of data points xq,yr.
The spline is given in the B-spline representation
sx,y = i=1 nx-4 j=1 ny-4 cij Mix Njy , (1)
where 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, with nx and ny the total numbers of knots of the computed spline with respect to the x and y variables respectively. For further details, see Hayes and Halliday (1974) for bicubic splines and de Boor (1972) for normalized B-splines. This function is suitable for B-spline representations returned by nag_2d_spline_interpolant (e01dac)nag_2d_spline_fit_panel (e02dac)nag_2d_spline_fit_grid (e02dcc) and nag_2d_spline_fit_scat (e02ddc).
The partial derivatives can be up to order 2 in each direction; thus the highest mixed derivative available is 4 x2 y2 .
The points in the grid are defined by coordinates xq, for q=1,2,,mx, along the x axis, and coordinates yr, for r=1,2,,my, along the y axis.

4  References

de Boor C (1972) On calculating with B-splines J. Approx. Theory 6 50–62
Dierckx P (1981) An improved algorithm for curve fitting with spline functions Report TW54 Department of Computer Science, Katholieke Univerciteit Leuven
Dierckx P (1982) A fast algorithm for smoothing data on a rectangular grid while using spline functions SIAM J. Numer. Anal. 19 1286–1304
Hayes J G and Halliday J (1974) The least squares fitting of cubic spline surfaces to general data sets J. Inst. Math. Appl. 14 89–103
Reinsch C H (1967) Smoothing by spline functions Numer. Math. 10 177–183

5  Arguments

1:     mxIntegerInput
On entry: mx, the number of grid points along the x axis.
Constraint: mx1.
2:     myIntegerInput
On entry: my, the number of grid points along the y axis.
Constraint: my1.
3:     x[mx]const doubleInput
On entry: x[q-1] must be set to xq, the x coordinate of the qth grid point along the x axis, for q=1,2,,mx, on which values of the partial derivative are sought.
Constraint: x1<x2<<xmx.
4:     y[my]const doubleInput
On entry: y[r-1] must be set to yr, the y coordinate of the rth grid point along the y axis, for r=1,2,,my on which values of the partial derivative are sought.
Constraint: y1<y2<<ymy.
5:     nuxIntegerInput
On entry: specifies the order, νx of the partial derivative in the x-direction.
Constraint: 0nux2.
6:     nuyIntegerInput
On entry: specifies the order, νy of the partial derivative in the y-direction.
Constraint: 0nuy2.
7:     z[mx×my]doubleOutput
On exit: z[my×q-1+r-1] contains the derivative νx+νy xνx yνy s xq,yr , for q=1,2,,mx and r=1,2,,my.
8:     splineNag_2dSpline *Input
Pointer to structure of type Nag_2dSpline describing the bicubic spline approximation to be differentiated.
In normal usage, the call to nag_2d_spline_deriv_rect (e02dhc) follows a call to nag_2d_spline_interpolant (e01dac), nag_2d_spline_fit_panel (e02dac), 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_deriv_rect (e02dhc).
9:     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_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, mx=value.
Constraint: mx1.
On entry, my=value.
Constraint: my1.
On entry, nux=value.
Constraint: 0nux2.
On entry, nuy=value.
Constraint: 0nuy2.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_NOT_STRICTLY_INCREASING
On entry, for i=value, x[i-2]=value and x[i-1]=value.
Constraint: x[i-2]x[i-1], for i=2,3,,mx.
On entry, for i=value, y[i-2]=value and y[i-1]=value.
Constraint: y[i-2]y[i-1], for i=2,3,,my.

7  Accuracy

On successful exit, the partial derivatives on the given mesh are accurate to machine precision with respect to the supplied bicubic spline. Please refer to Section 7 in nag_2d_spline_interpolant (e01dac)nag_2d_spline_fit_panel (e02dac)nag_2d_spline_fit_grid (e02dcc) and nag_2d_spline_fit_scat (e02ddc) of the function document for the respective function which calculated the spline approximant for details on the accuracy of that approximation.

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  Example

This example reads in values of mx, my, xq, for q=1,2,,mx, and yr, for r=1,2,,my, followed by values of the ordinates fq,r defined at the grid points xq,yr. It then calls nag_2d_spline_fit_grid (e02dcc) to compute a bicubic spline approximation for one specified value of S. Finally it evaluates the spline and its first x derivative at a small sample of points on a rectangular grid by calling nag_2d_spline_deriv_rect (e02dhc).

10.1  Program Text

Program Text (e02dhce.c)

10.2  Program Data

Program Data (e02dhce.d)

10.3  Program Results

Program Results (e02dhce.r)


nag_2d_spline_deriv_rect (e02dhc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

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