Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_2dspline_sort (e02za)

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$m$ data points with rectangular Cartesian coordinates xr,yr${x}_{r},{y}_{r}$ are sorted into panels defined by lines parallel to the y$y$ and x$x$ axes. The intercepts of these lines on the x$x$ and y$y$ axes are given in lamda(i)${\mathbf{lamda}}\left(\mathit{i}\right)$, for i = 5,6,,px4$\mathit{i}=5,6,\dots ,{\mathbf{px}}-4$ and mu(j)${\mathbf{mu}}\left(\mathit{j}\right)$, for j = 5,6,,py4$\mathit{j}=5,6,\dots ,{\mathbf{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
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 (px7) × (py7)$\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.

None.

Parameters

Compulsory Input Parameters

1:     lamda(px) – double array
px, the dimension of the array, must satisfy the constraint px8${\mathbf{px}}\ge 8$ and py8${\mathbf{py}}\ge 8$.
lamda(5)${\mathbf{lamda}}\left(5\right)$ to lamda(px4)${\mathbf{lamda}}\left({\mathbf{px}}-4\right)$ must contain, in nondecreasing order, the intercepts on the x$x$ axis of the sides of the panels parallel to the y$y$ axis.
2:     mu(py) – double array
py, the dimension of the array, must satisfy the constraint px8${\mathbf{px}}\ge 8$ and py8${\mathbf{py}}\ge 8$.
mu(5)${\mathbf{mu}}\left(5\right)$ to mu(py4)${\mathbf{mu}}\left({\mathbf{py}}-4\right)$ must contain, in nondecreasing order, the intercepts on the y$y$ axis of the sides of the panels parallel to the x$x$ axis.
3:     x(m) – double array
4:     y(m) – double array
The coordinates of the r$\mathit{r}$th data point (xr,yr)$\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,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$x$ axis and y$y$ axis, respectively.
Constraint: px8${\mathbf{px}}\ge 8$ and py8${\mathbf{py}}\ge 8$.
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$m$ of data points.

Output Parameters

1:     point(npoint) – int64int32nag_int array
npointm + (px7) × (py7)$\mathit{npoint}\ge {\mathbf{m}}+\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.
For i = 1,2,,npoint$i=1,2,\dots ,\mathit{npoint}$, point(m + i) = I1${\mathbf{point}}\left(m+i\right)=\mathrm{I1}$ is the index of the first point in panel i$i$, point(I1) = I2${\mathbf{point}}\left(\mathrm{I1}\right)=\mathrm{I2}$ is the index of the second point in panel i$i$ and so on.
point(In) = 0${\mathbf{point}}\left(\mathrm{In}\right)=0$ indicates that x(In),y(In)${\mathbf{x}}\left(\mathrm{In}\right),{\mathbf{y}}\left(\mathrm{In}\right)$ was the last point in the panel.
The coordinates of points in panel i$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
${\mathrm{ifail}}={\mathbf{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${\mathbf{ifail}}=1$
The intercepts in the array lamda, or in the array mu, are not in nondecreasing order.
ifail = 2${\mathbf{ifail}}=2$
 On entry, px < 8${\mathbf{px}}<8$, or py < 8${\mathbf{py}}<8$, or m ≤ 0${\mathbf{m}}\le 0$, or nadres ≠ (px − 7) × (py − 7)$\mathit{nadres}\ne \left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$, or npoint < m + (px − 7) × (py − 7)$\mathit{npoint}<{\mathbf{m}}+\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.

Accuracy

Not applicable.

The time taken is approximately proportional to m × log(npoint)$m×\mathrm{log}\left(\mathit{npoint}\right)$.
This function was written to sort two-dimensional data in the manner required by function nag_fit_2dspline_panel (e02da). The first 9$9$ parameters of nag_fit_2dspline_sort (e02za) are the same as the parameters in nag_fit_2dspline_panel (e02da) which have the same name.

Example

```function nag_fit_2dspline_sort_example
lamda = [0;
0;
0;
0;
1;
0;
0;
0;
0];
mu = [0;
0;
0;
0;
0.8;
1.2;
0;
0;
0;
0];
x = [0;
0.7;
1.44;
0.21;
1.01;
1.84;
0.71;
1;
0.54;
1.53];
y = [0.77;
1.06;
0.33;
0.44;
0.5;
0.02;
1.95;
1.2;
0.04;
0.18];
[point, ifail] = nag_fit_2dspline_sort(lamda, mu, x, y)
```
```

point =

4
0
5
9
6
10
0
0
0
0
1
2
7
3
0
8

ifail =

0

```
```function e02za_example
lamda = [0;
0;
0;
0;
1;
0;
0;
0;
0];
mu = [0;
0;
0;
0;
0.8;
1.2;
0;
0;
0;
0];
x = [0;
0.7;
1.44;
0.21;
1.01;
1.84;
0.71;
1;
0.54;
1.53];
y = [0.77;
1.06;
0.33;
0.44;
0.5;
0.02;
1.95;
1.2;
0.04;
0.18];
[point, ifail] = e02za(lamda, mu, x, y)
```
```

point =

4
0
5
9
6
10
0
0
0
0
1
2
7
3
0
8

ifail =

0

```