# NAG FL Interfacee02zaf (dim2_​spline_​sort)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e02zaf sorts two-dimensional data into rectangular panels.

## 2Specification

Fortran Interface
 Subroutine e02zaf ( px, py, mu, m, x, y,
 Integer, Intent (In) :: px, py, m, npoint, nadres Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: point(npoint), adres(nadres) Real (Kind=nag_wp), Intent (In) :: lamda(px), mu(py), x(m), y(m)
#include <nag.h>
 void e02zaf_ (const Integer *px, const Integer *py, const double lamda[], const double mu[], const Integer *m, const double x[], const double y[], Integer point[], const Integer *npoint, Integer adres[], const Integer *nadres, Integer *ifail)
The routine may be called by the names e02zaf or nagf_fit_dim2_spline_sort.

## 3Description

A set of $m$ data points with rectangular Cartesian coordinates ${x}_{r},{y}_{r}$ 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 ${\mathbf{lamda}}\left(\mathit{i}\right)$, for $\mathit{i}=5,6,\dots ,{\mathbf{px}}-4$ and ${\mathbf{mu}}\left(\mathit{j}\right)$, for $\mathit{j}=5,6,\dots ,{\mathbf{py}}-4$, respectively. The subroutine 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.
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 subroutine 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 $\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.

None.

## 5Arguments

1: $\mathbf{px}$Integer Input
2: $\mathbf{py}$Integer Input
On entry: px and py must specify eight more than the number of intercepts on the $x$ axis and $y$ axis, respectively.
Constraint: ${\mathbf{px}}\ge 8$ and ${\mathbf{py}}\ge 8$.
3: $\mathbf{lamda}\left({\mathbf{px}}\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{lamda}}\left(5\right)$ to ${\mathbf{lamda}}\left({\mathbf{px}}-4\right)$ must contain, in nondecreasing order, the intercepts on the $x$ axis of the sides of the panels parallel to the $y$ axis.
4: $\mathbf{mu}\left({\mathbf{py}}\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{mu}}\left(5\right)$ to ${\mathbf{mu}}\left({\mathbf{py}}-4\right)$ must contain, in nondecreasing order, the intercepts on the $y$ axis of the sides of the panels parallel to the $x$ axis.
5: $\mathbf{m}$Integer Input
On entry: the number $m$ of data points.
6: $\mathbf{x}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
7: $\mathbf{y}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
On entry: the coordinates of the $\mathit{r}$th data point $\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$.
8: $\mathbf{point}\left({\mathbf{npoint}}\right)$Integer array Output
On exit: for $i=1,2,\dots ,{\mathbf{npoint}}$, ${\mathbf{point}}\left(m+i\right)=\mathrm{I1}$ is the index of the first point in panel $i$, ${\mathbf{point}}\left(\mathrm{I1}\right)=\mathrm{I2}$ is the index of the second point in panel $i$ and so on.
${\mathbf{point}}\left(\mathrm{In}\right)=0$ indicates that ${\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$ can be accessed in turn by means of the following instructions:
```in = m + i
10 in = point(in)
If (in.eq. 0) Goto 20
xi = x(in)
yi = y(in)
.
.
.
Goto 10
20 ...```
9: $\mathbf{npoint}$Integer Input
On entry: the dimension of the array point as declared in the (sub)program from which e02zaf is called.
Constraint: ${\mathbf{npoint}}\ge {\mathbf{m}}+\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.
10: $\mathbf{adres}\left({\mathbf{nadres}}\right)$Integer array Workspace
11: $\mathbf{nadres}$Integer Input
On entry: the value $\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$, the number of panels into which the $\left(x,y\right)$ plane is divided.
12: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, $\mathit{I}=⟨\mathit{\text{value}}⟩$, ${\mathbf{lamda}}\left(\mathit{I}\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{lamda}}\left(\mathit{I}-1\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lamda}}\left(\mathit{I}\right)\ge {\mathbf{lamda}}\left(\mathit{I}-1\right)$.
On entry, $\mathit{I}=⟨\mathit{\text{value}}⟩$, ${\mathbf{mu}}\left(\mathit{I}\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{mu}}\left(\mathit{I}-1\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mu}}\left(\mathit{I}\right)\ge {\mathbf{mu}}\left(\mathit{I}-1\right)$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}>0$.
On entry, ${\mathbf{nadres}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{px}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{py}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nadres}}=\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.
On entry, ${\mathbf{npoint}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{px}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{py}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{npoint}}\ge {\mathbf{m}}+\left({\mathbf{px}}-7\right)×\left({\mathbf{py}}-7\right)$.
On entry, ${\mathbf{px}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{px}}\ge 8$.
On entry, ${\mathbf{py}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{py}}\ge 8$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

e02zaf is not threaded in any implementation.

The time taken is approximately proportional to $m×\mathrm{log}\left({\mathbf{npoint}}\right)$.
This subroutine was written to sort two-dimensional data in the manner required by routine e02daf. The first $9$ arguments of e02zaf are the same as the arguments in e02daf which have the same name.

## 10Example

This example reads in data points and the intercepts of the panel sides on the $x$ and $y$ axes; it calls e02zaf to set up the index array point; and finally it prints the data points in panel order.

### 10.1Program Text

Program Text (e02zafe.f90)

### 10.2Program Data

Program Data (e02zafe.d)

### 10.3Program Results

Program Results (e02zafe.r)