NAG C Library Function Document

nag_2d_panel_sort (e02zac)


nag_2d_panel_sort (e02zac) sorts two-dimensional data into rectangular panels.


#include <nag.h>
#include <nage02.h>
void  nag_2d_panel_sort (Integer px, Integer py, const double lamda[], const double mu[], Integer m, const double x[], const double y[], Integer point[], NagError *fail)


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 lamda[i-1], for i=5,6,,px-4 and mu[j-1], 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.




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] const doubleInput
On entry: lamda[4] to lamda[px-5] 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] const doubleInput
On entry: mu[4] to mu[py-5] 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] const doubleInput
7:     y[m] const doubleInput
On entry: the coordinates of the rth data point xr,yr, for r=1,2,,m.
8:     point[dim] IntegerOutput
Note: the dimension, dim, of the array point must be at least m+px-7×py-7.
On exit: for i=1,2,,m+px-7×py-7, point[m+i-1]=I1 is the index of the first point in panel i, point[I1-1]=I2 is the index of the second point in panel i and so on.
point[In-1]=0 indicates that x[In-1],y[In-1] was the last point in the panel.
9:     fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

Error Indicators and Warnings

Dynamic memory allocation failed.
See Section in How to Use the NAG Library and its Documentation for further information.
On entry, argument value had an illegal value.
On entry, m=value.
Constraint: m>0.
On entry, px=value.
Constraint: px8.
On entry, py=value.
Constraint: py8.
On entry, px=value and py=value.
Constraint: px8 and py8.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
On entry, I=value, lamda[I-1]=value and lamda[I-2]=value.
Constraint: lamda[I-1]lamda[I-2].
On entry, I=value, mu[I-1]=value and mu[I-2]=value.
Constraint: mu[I-1]mu[I-2].


Not applicable.

Parallelism and Performance

nag_2d_panel_sort (e02zac) is not threaded in any implementation.

Further Comments

The time taken is approximately proportional to m×logm+px-7×py-7.
This function was written to sort two-dimensional data in the manner required by function nag_2d_spline_fit_panel (e02dac). The first 9 arguments of nag_2d_panel_sort (e02zac) are the same as the arguments in nag_2d_spline_fit_panel (e02dac) which have the same name.


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

Program Text

Program Text (e02zace.c)

Program Data

Program Data (e02zace.d)

Program Results

Program Results (e02zace.r)