hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_2dspline_evalm (e02df)

Purpose

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

Syntax

[ff, ifail] = e02df(x, y, lamda, mu, c, 'mx', mx, 'my', my, 'px', px, 'py', py)
[ff, ifail] = nag_fit_2dspline_evalm(x, y, lamda, mu, c, 'mx', mx, 'my', my, 'px', px, 'py', py)

Description

nag_fit_2dspline_evalm (e02df) calculates values of the bicubic spline s(x,y)s(x,y) on a rectangular grid of points in the xx-yy plane, from its augmented knot sets {λ}{λ} and {μ}{μ} and from the coefficients cijcij, for i = 1,2,,px4i=1,2,,px-4 and j = 1,2,,py4j=1,2,,py-4, in its B-spline representation
s(x,y) =  cijMi(x)Nj(y).
ij
s(x,y) = ij cij Mi(x) Nj(y) .
Here Mi(x)Mi(x) and Nj(y)Nj(y) denote normalized cubic B-splines, the former defined on the knots λiλi to λi + 4λi+4 and the latter on the knots μjμj to μj + 4μj+4.
The points in the grid are defined by coordinates xqxq, for q = 1,2,,mxq=1,2,,mx, along the xx axis, and coordinates yryr, for r = 1,2,,myr=1,2,,my, along the yy axis.
This function may be used to calculate values of a bicubic spline given in the form produced by nag_interp_2d_spline_grid (e01da), nag_fit_2dspline_panel (e02da), nag_fit_2dspline_grid (e02dc) and nag_fit_2dspline_sctr (e02dd). It is derived from the function B2VRE in Anthony et al. (1982).

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

Parameters

Compulsory Input Parameters

1:     x(mx) – double array
2:     y(my) – double array
mx, the dimension of the array, must satisfy the constraint mx1mx1 and my1my1.
x and y must contain xqxq, for q = 1,2,,mxq=1,2,,mx, and yryr, for r = 1,2,,myr=1,2,,my, respectively. These are the xx and yy coordinates that define the rectangular grid of points at which values of the spline are required.
Constraint: xx and y must satisfy
lamda(4) x(q) < x(q + 1) lamda(px3) ,   q = 1,2,,mx1
lamda4 xq < xq+1 lamdapx-3 ,   q=1,2,,mx-1
and
mu(4) y(r) < y(r + 1) mu(py3) ,   r = 1,2,,my 1 .
mu4 yr < yr+1 mupy-3 ,   r= 1,2,,my- 1 .
.
The spline representation is not valid outside these intervals.
3:     lamda(px) – double array
4:     mu(py) – double array
px, the dimension of the array, must satisfy the constraint px8px8 and py8py8.
lamda and mu must contain the complete sets of knots {λ}{λ} and {μ}{μ} associated with the xx and yy variables respectively.
Constraint: the knots in each set must be in nondecreasing order, with lamda(px3) > lamda(4)lamdapx-3>lamda4 and mu(py3) > mu(4)mupy-3>mu4.
5:     c((px4) × (py4)(px-4)×(py-4)) – double array
c((py4) × (i1) + j)c((py-4)×(i-1)+j) must contain the coefficient cijcij described in Section [Description], for i = 1,2,,px4i=1,2,,px-4 and j = 1,2,,py4j=1,2,,py-4.

Optional Input Parameters

1:     mx – int64int32nag_int scalar
2:     my – int64int32nag_int scalar
Default: The dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
mx and my must specify mxmx and mymy respectively, the number of points along the xx and yy axis that define the rectangular grid.
Constraint: mx1mx1 and my1my1.
3:     px – int64int32nag_int scalar
4:     py – int64int32nag_int scalar
Default: For px, the dimension of the array lamda. For py, the dimension of the array mu.
px and py must specify the total number of knots associated with the variables xx and yy respectively. They are such that px8px-8 and py8py-8 are the corresponding numbers of interior knots.
Constraint: px8px8 and py8py8.

Input Parameters Omitted from the MATLAB Interface

wrk lwrk iwrk liwrk

Output Parameters

1:     ff(mx × mymx×my) – double array
ff(my × (q1) + r)ffmy×(q-1)+r contains the value of the spline at the point (xq,yr)(xq,yr), for q = 1,2,,mxq=1,2,,mx and r = 1,2,,myr=1,2,,my.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,mx < 1mx<1,
ormy < 1my<1,
orpy < 8py<8,
orpx < 8px<8.
  ifail = 2ifail=2
On entry,lwrk is too small,
orliwrk is too small.
  ifail = 3ifail=3
On entry, the knots in array lamda, or those in array mu, are not in nondecreasing order, or lamda(px3)lamda(4)lamdapx-3lamda4, or mu(py3)mu(4)mupy-3mu4.
  ifail = 4ifail=4
On entry, the restriction lamda(4)x(1) < < x(mx)lamda(px3)lamda4x1<<xmxlamdapx-3, or the restriction mu(4)y(1) < < y(my)mu(py3)mu4y1<<ymymupy-3, is violated.

Accuracy

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

Further Comments

Computation time is approximately proportional to mxmy + 4(mx + my)mxmy+4(mx+my).

Example

function nag_fit_2dspline_evalm_example
x = [1;
     1.1;
     1.3;
     1.4;
     1.5;
     1.7;
     2];
y = [0;
     0.2;
     0.4;
     0.6;
     0.8;
     1];
lamda = [1;
     1;
     1;
     1;
     1.3;
     1.5;
     1.6;
     2;
     2;
     2;
     2];
mu = [0;
     0;
     0;
     0;
     0.4;
     0.7;
     1;
     1;
     1;
     1];
c = [1;
     1.1333;
     1.3667;
     1.7;
     1.9;
     2;
     1.2;
     1.3333;
     1.5667;
     1.9;
     2.1;
     2.2;
     1.5833;
     1.7167;
     1.95;
     2.2833;
     2.4833;
     2.5833;
     2.1433;
     2.2767;
     2.51;
     2.8433;
     3.0433;
     3.1433;
     2.8667;
     3;
     3.2333;
     3.5667;
     3.7667;
     3.8667;
     3.4667;
     3.6;
     3.8333;
     4.1667;
     4.3667;
     4.4667;
     4;
     4.1333;
     4.3667;
     4.7;
     4.9;
     5];
[ff, ifail] = nag_fit_2dspline_evalm(x, y, lamda, mu, c)
 

ff =

    1.0000
    1.2000
    1.4000
    1.6000
    1.8000
    2.0000
    1.2100
    1.4100
    1.6100
    1.8100
    2.0100
    2.2100
    1.6900
    1.8900
    2.0900
    2.2900
    2.4900
    2.6900
    1.9600
    2.1600
    2.3600
    2.5600
    2.7600
    2.9600
    2.2500
    2.4500
    2.6500
    2.8500
    3.0500
    3.2500
    2.8900
    3.0900
    3.2900
    3.4900
    3.6900
    3.8900
    4.0000
    4.2000
    4.4000
    4.6000
    4.8000
    5.0000


ifail =

                    0


function e02df_example
x = [1;
     1.1;
     1.3;
     1.4;
     1.5;
     1.7;
     2];
y = [0;
     0.2;
     0.4;
     0.6;
     0.8;
     1];
lamda = [1;
     1;
     1;
     1;
     1.3;
     1.5;
     1.6;
     2;
     2;
     2;
     2];
mu = [0;
     0;
     0;
     0;
     0.4;
     0.7;
     1;
     1;
     1;
     1];
c = [1;
     1.1333;
     1.3667;
     1.7;
     1.9;
     2;
     1.2;
     1.3333;
     1.5667;
     1.9;
     2.1;
     2.2;
     1.5833;
     1.7167;
     1.95;
     2.2833;
     2.4833;
     2.5833;
     2.1433;
     2.2767;
     2.51;
     2.8433;
     3.0433;
     3.1433;
     2.8667;
     3;
     3.2333;
     3.5667;
     3.7667;
     3.8667;
     3.4667;
     3.6;
     3.8333;
     4.1667;
     4.3667;
     4.4667;
     4;
     4.1333;
     4.3667;
     4.7;
     4.9;
     5];
[ff, ifail] = e02df(x, y, lamda, mu, c)
 

ff =

    1.0000
    1.2000
    1.4000
    1.6000
    1.8000
    2.0000
    1.2100
    1.4100
    1.6100
    1.8100
    2.0100
    2.2100
    1.6900
    1.8900
    2.0900
    2.2900
    2.4900
    2.6900
    1.9600
    2.1600
    2.3600
    2.5600
    2.7600
    2.9600
    2.2500
    2.4500
    2.6500
    2.8500
    3.0500
    3.2500
    2.8900
    3.0900
    3.2900
    3.4900
    3.6900
    3.8900
    4.0000
    4.2000
    4.4000
    4.6000
    4.8000
    5.0000


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013