# Detailed description of the procedures for shgrid

## SHGRID - interpolate random data in 3-space using a modified Shepard's algorithm

SHGRID is called to interpolate randomly spaced data in 3-space.

SHGRID uses a modified Shepard's algorithm to construct an interpolatory surface. For details on the algorithm, see the introduction module.

```------------------------------------------------------------------
Argument | Type    |  Mode  | Dimension
------------------------------------------------------------------
CALL SHGRID (N,       | Integer | Input  |
X,       | Real    | Input  | N
Y,       | Real    | Input  | N
Z,       | Real    | Input  | N
F,       | Real    | Input  | N
NXO,     | Integer | Input  |
NYO,     | Integer | Input  |
NZO,     | Integer | Input  |
XO,      | Real    | Input  | NXO
YO,      | Real    | Input  | NYO
ZO,      | Real    | Input  | NZO
FF,      | Real    | Input  | NXO x NYO x NZO
IWK,     | Integer | Input  | 2*N
RWK,     | Real    | Input  | 11*N+6
IER)     | Integer | Output |
------------------------------------------------------------------
```
N
The number of input data points (N > 9).
X,Y,Z
Arrays containing Cartesian coordinates of the input data. An error results if the input data are collinear.
F
Array containing data values. F(I) is a functional value at (X(I),Y(I),Z(I)) for I = 1 to N.
NXO
The dimension of the array XO containing the X coordinate values for the output grid.
NYO
The dimension of the array YO containing the Y coordinate values for the output grid.
NZO
The dimension of the array ZO containing the Z coordinate values for the output grid.
XO
An array containing the X coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
YO
An array containing the Y coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
ZO
An array containing the Z coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
FF
Interpolated values at the grid points if IER .EQ. 0 . FF(I,J,K) = F(XO(I),YO(J),ZO(K)) for I=1,...,NXO and J=1,...,NYO and K=1,NZO.
IWK
An integer workspace of length at least 2*N.
RWK
A real workspace of length at least 11*N+6.
IER
An error return value. If IER is returned as 0, then no errors were detected. If IER is non-zero, then refer to the error list in the error table for details.

## SHGETNP - find the nearest points to a specified point in 3-space

SHGETNP is called to find the nearest point to a specified point in 3-space. Successive calls to SHGETNP will determine the point nearest the specified point exclusive of the points found in previous calls, i.e. successive calls can be used to find the N nearest points for any N between one and the maximum number of points in the input dataset.
```------------------------------------------------------------------
Argument | Type    |  Mode  | Dimension
------------------------------------------------------------------
CALL SHGETNP (PX,      | Real    | Input  |
PY,      | Real    | Input  |
PZ,      | Real    | Input  |
N,       | Integer | Input  |
X,       | Real    | Input  | N
Y,       | Real    | Input  | N
Z,       | Real    | Input  | N
IFLAG,   | Integer | Input  |
IWK,     | Integer | Input  | 2*N
RWK,     | Real    | Input  | 11*N+6
NP,      | Integer | Output |
IER)     | Integer | Output |
------------------------------------------------------------------
```
PX
The X coordinate value for a point P whose nearest neighbor is to be found.
PY
The Y coordinate value for a point P whose nearest neighbor is to be found.
PZ
The Z coordinate value for a point P whose nearest neighbor is to be found.
N
The number of input data points, N > 1.
X
An array of length N containing the X coordinate values for the input data points.
Y
An array of length N containing the Y coordinate values for the input data points.
Z
An array of length N containing the Z coordinate values for the input data points.
IFLAG
A flag that equals 0 if this is the first call to this subroutine for the given dataset and equals 1 otherwise.
IWK
An integer workspace dimensioned for at least 2*N.
RWK
A real workspace dimensioned for at least 11*N+6.
NP
An index such that (X(NP),Y(NP),Z(NP)) is the nearest input data point to P. NP = 0 if IER .NE. 0. On successive calls to this subroutine after the first (that is when IFLAG=1) you can find the Mth closest point to (PX,PY,PZ) with the Mth call. IWK and RWK should not be modified between calls to SHGETNP if you are wanting to find successive nearest neighbors.
IER
An error return value. If IER is returned as 0, then no errors were detected. If IER is non-zero, then refer to the error list in the error table for details.

## SHSETI - set values for control parameters

SGHSETI is used to set values for any of the control parameters that take integer values. The values set by SHSETI remain in effect until changed by subsequent calls to SHSETI.
```-----------------------------------------------------
Argument | Type      |  Mode  | Dimension
-----------------------------------------------------
CALL SHSETI (PNAM,   | Character | Input  |
IVAL)   | Integer   | Input  |
-----------------------------------------------------
```
PNAM
The name of the control parameter to be set.
IVAL
The value to be assigned to the parameter.

## SHGETI - retrieve values for INTEGER parameters

SHGETI is a called to retrieve current values for any of the INTEGER valued control parameters.
```-----------------------------------------------------
Argument | Type      |  Mode  | Dimension
-----------------------------------------------------
CALL SHGETI (PNAM,   | Character | Input  |
IVAL)   | Integer   | Output |
-----------------------------------------------------
```
PNAM
The name of the control p arameter whose value is to be retrieved.
IVAL
The current value assigned to the control parameter.

## c_shgrid - interpolate random data in 3-space using a modified Shepard's algorithm

c_shgrid is called to interpolate randomly spaced data in 3-space.

c_shgrid uses a modified Shepard's algorithm to construct an interpolatory surface. For details on the algorithm, see the introduction module.

Function prototype:

```  float *c_shgrid(int, float [], float [], float [], float [],
int, int, int, float [], float [], float [], int*);
```

Usage:

```-------------------------------------------------
Argument | Type     |  Size
-------------------------------------------------
float *c_shgrid (n,       | int      |
x,       | float [] | n
y,       | float [] | n
z,       | float [] | n
f,       | float [] | n
nxo,     | int      |
nyo,     | int      |
nzo,     | int      |
xo,      | float [] | nxo
yo,      | float [] | nyo
zo,      | float [] | nzo
ier      | int *    |
);
-------------------------------------------------
```
n
The number of input data points, n > 9.
x,y,z
Arrays containing Cartesian coordinates of the input data. An error results if the input data are collinear.
f
Array containing data values. f[i] is the functional value at (x[i],y[i],z[i]) for i = 0 to n-1.
nxo
The size of the array xo containing the X coordinate values for the output grid.
nyo
The size of the array yo containing the Y coordinate values for the output grid.
nzo
The size of the array zo containing the Z coordinate values for the output grid.
xo
An array containing the X coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
yo
An array containing the Y coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
zo
An array containing the Z coordinate values for the output grid (must be monotone increasing, but need not be equally spaced.
ier
An error return value. If *ier is returned as 0, then no errors were detected. If *ier is non-zero, then refer to the error list in the error table for details.
Return value:

c_shgrid returns a pointer to a linear array of data that is the interpolated grid stored in row-major order. That is, if out is declared as

```  float *out;
```
and we set:
```  out = c_shgrid(n, x, y, z, f, nxo, nyo, nzo, xo, yo, zo, ier);
```
then out[nz*ny*i + nz*j + k] is the interpolated function value at coordinate point (xo[i], yo[j], zo[k]) for 0 <= i < nxo, 0 <= j < nyo, and 0 <= k < nzo. The space for out is allocated internal to c_shgrid and is nxo*nyo*nzo floats in size.

## c_shgetnp - find the nearest points to a specified point in 3-space

c_shgetnp is called to find the nearest point to a specified point in 3-space. Successive calls to c_shgetnp will determine the point nearest the specified point exclusive of the points found in previous calls, i.e. successive calls can be used to find the N nearest points for any N between one and the maximum number of points in the input dataset.

Function prototype:

```  int c_shgetnp(float, float, float, int, float *, float *, float *,
int, int *);

```
Usage:
```
-------------------------------------------------
Argument | Type     |  Size
-------------------------------------------------
int c_shgetnp (px,      | float    |
py,      | float    |
pz,      | float    |
n,       | int      |
x,       | float [] | n
y,       | float [] | n
z,       | float [] | n
iflag,   | int      |
ier      | int *    |
);
-------------------------------------------------
```
px
The X coordinate value for a point P whose nearest neighbor is to be found.
py
The Y coordinate value for a point P whose nearest neighbor is to be found.
pz
The Z coordinate value for a point P whose nearest neighbor is to be found.
n
The number of input data points, n > 1.
x
An array of length n containing the X coordinate values for the input data points.
y
An array of length n containing the Y coordinate values for the input data points.
z
An array of length n containing the Z coordinate values for the input data points.
iflag
A flag that equals 0 if this is the first call to this subroutine for the given dataset and equals 1 otherwise.
ier
An error return value. If *ier is returned as 0, then no errors were detected. If *ier is non-zero, then refer to the error list in the error table for details.
Return value:

c_shgetnp returns an integer, say np, such that (x[np],y[np],z[np]) is the nearest input data point to P. np = -1 if *ier is not zero. On successive calls to this function after the first (that is when iflag=1) you can find the Mth closest point to (px,py,pz) with the Mth call.

## c_shseti - Set int valued parameters

c_shseti is used to set values for any of the control parameters that take int values. The values set by c_shseti remain in effect until changed by subsequent calls to c_shseti.

Function prototype:

```  void c_shseti(char *, int);
```
Argument description:
```-------------------------------------------
Argument | Type    |  Size
-------------------------------------------
void c_shseti (pnam,   | char *  |
ival);  | int     |
-------------------------------------------
```
pnam
The name of the control parameter to be assigned an int value.
ival
The value to be assigned to the control parameter whose name is pointed to by pnam.

## c_shgeti - Retrieve an int valued parameter

c_shgeti is a called to obtain current values for any of the int valued control parameters.

Function prototype:

```  void c_shgeti(char *, int);
```
Argument description:
```-------------------------------------------
Argument | Type    |  Size
-------------------------------------------
void c_shgeti (pnam,   | char *  |
ival);  | int  *  |
-------------------------------------------
```
pnam
The name of the control parameter whose value is to be retrieved.
ival
*ival will be the value currently assigned to the control parameter whose name is pointed to by pnam.

home | contents | defs | procedures | examples | errors