E02ZAF (PDF version)
E02 Chapter Contents
E02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

E02ZAF sorts two-dimensional data into rectangular panels.

2  Specification

REAL (KIND=nag_wp)  LAMDA(PX), MU(PY), X(M), Y(M)

3  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 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.
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 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 PX-7×PY-7.

4  References


5  Parameters

1:     PX – INTEGERInput
2:     PY – INTEGERInput
On entry: 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:     LAMDA(PX) – REAL (KIND=nag_wp) arrayInput
On entry: 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.
4:     MU(PY) – REAL (KIND=nag_wp) arrayInput
On entry: 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.
5:     M – INTEGERInput
On entry: the number m of data points.
6:     X(M) – REAL (KIND=nag_wp) arrayInput
7:     Y(M) – REAL (KIND=nag_wp) arrayInput
On entry: the coordinates of the rth data point xr,yr, for r=1,2,,m.
8:     POINT(NPOINT) – INTEGER arrayOutput
On exit: 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 = M + I 10 IN = POINT(IN) IF (IN.EQ. 0) GOTO 20 XI = X(IN) YI = Y(IN) . . . GOTO 10 20 ... 
9:     NPOINT – INTEGERInput
On entry: the dimension of the array POINT as declared in the (sub)program from which E02ZAF is called.
Constraint: NPOINTM+PX-7×PY-7.
10:   ADRES(NADRES) – INTEGER arrayWorkspace
On entry: the value PX-7×PY-7, the number of panels into which the x,y plane is divided.
12:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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:
The intercepts in the array LAMDA, or in the array MU, are not in nondecreasing order.
On entry,PX<8,

7  Accuracy

Not applicable.

8  Further Comments

The time taken is approximately proportional to m×logNPOINT.
This subroutine was written to sort two-dimensional data in the manner required by routine E02DAF. The first 9 parameters of E02ZAF are the same as the parameters in E02DAF which have the same name.

9  Example

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.

9.1  Program Text

Program Text (e02zafe.f90)

9.2  Program Data

Program Data (e02zafe.d)

9.3  Program Results

Program Results (e02zafe.r)

E02ZAF (PDF version)
E02 Chapter Contents
E02 Chapter Introduction
NAG Library Manual

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