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_sort (e02za)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_fit_2dspline_sort (e02za) sorts two-dimensional data into rectangular panels.

Syntax

[point, ifail] = e02za(lamda, mu, x, y, 'px', px, 'py', py, 'm', m)
[point, ifail] = nag_fit_2dspline_sort(lamda, mu, x, y, 'px', px, 'py', py, 'm', m)

Description

A set of m data points with rectangular Cartesian coordinates xr,yr are sorted into panels defined by lines parallel to the y and x axes. The intercepts of these lines on the x and y axes are given in lamdai, for i=5,6,,px-4 and muj, for j=5,6,,py-4, respectively. The function orders the data so that all points in a panel occur before data in succeeding panels, where the panels are numbered from bottom to top and then left to right, with the usual arrangement of axes, as shown in the diagram. Within a panel the points maintain their original order.
Figure 1
Figure 1
A data point lying exactly on one or more panel sides is taken to be in the highest-numbered panel adjacent to the point. The function does not physically rearrange the data, but provides the array point which contains a linked list for each panel, pointing to the data in that panel. The total number of panels is px-7×py-7.

References

None.

Parameters

Compulsory Input Parameters

1:     lamdapx – double array
lamda5 to lamdapx-4 must contain, in nondecreasing order, the intercepts on the x axis of the sides of the panels parallel to the y axis.
2:     mupy – double array
mu5 to mupy-4 must contain, in nondecreasing order, the intercepts on the y axis of the sides of the panels parallel to the x axis.
3:     xm – double array
4:     ym – double array
The coordinates of the rth data point xr,yr, for r=1,2,,m.

Optional Input Parameters

1:     px int64int32nag_int scalar
2:     py int64int32nag_int scalar
Default: the dimension of the arrays lamda, mu. (An error is raised if these dimensions are not equal.)
px and py must specify eight more than the number of intercepts on the x axis and y axis, respectively.
Constraint: px8 and py8.
3:     m int64int32nag_int scalar
Default: the dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
The number m of data points.

Output Parameters

1:     pointnpoint int64int32nag_int array
npoint=m+px-7×py-7.
For i=1,2,,npoint, pointm+i=I1 is the index of the first point in panel i, pointI1=I2 is the index of the second point in panel i and so on.
pointIn=0 indicates that xIn,yIn was the last point in the panel.
The coordinates of points in panel i can be accessed in turn by means of the following instructions:
 in = point(m+i);

 while (in ~= 0)

 xi = x(in);

 yi = y(in);

 .

 .

 .

 in = point(in);

 end

 ... 
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
The intercepts in the array lamda, or in the array mu, are not in nondecreasing order.
   ifail=2
On entry,px<8,
orpy<8,
orm0,
ornadrespx-7×py-7,
ornpoint<m+px-7×py-7.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

The time taken is approximately proportional to m×lognpoint.
This function was written to sort two-dimensional data in the manner required by function nag_fit_2dspline_panel (e02da). The first 9 arguments of nag_fit_2dspline_sort (e02za) are the same as the arguments in nag_fit_2dspline_panel (e02da) which have the same name.

Example

This example reads in data points and the intercepts of the panel sides on the x and y axes; it calls nag_fit_2dspline_sort (e02za) to set up the index array point; and finally it prints the data points in panel order.
function e02za_example


fprintf('e02za example results\n\n');

xknots = [1];       kx = size(xknots,2);
yknots = [0.8 1.2]; ky = size(yknots,2);

lamda = zeros(kx+8,1);
mu    = zeros(ky+8,1);
lamda(5:kx+4) = xknots;
mu(5:ky+4)    = yknots;

x = [0.00  0.70  1.44  0.21  1.01  1.84  0.71  1.00  0.54  1.53];
y = [0.77  1.06  0.33  0.44  0.50  0.02  1.95  1.20  0.04  0.18];
m = size(x,2);

[point, ifail] = e02za(lamda, mu, x, y);

% Output points in panel order

for i = 1:(kx+1)*(ky+1)
  fprintf('\nPanel %4d\n', i);
  ip = m + i;

  while ip>0
    ip = point(ip);
    if (ip>0)
      fprintf('%7.2f%7.2f\n',x(ip), y(ip));
    end
  end
end


e02za example results


Panel    1
   0.00   0.77
   0.21   0.44
   0.54   0.04

Panel    2
   0.70   1.06

Panel    3
   0.71   1.95

Panel    4
   1.44   0.33
   1.01   0.50
   1.84   0.02
   1.53   0.18

Panel    5

Panel    6
   1.00   1.20

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–2015