HTML automatically generated with rman
Table of Contents

Name

inil_grid, inia_grid, inip_grid, index_grid, value_grid - various (1D) gridding routines

Synopsis


#include <grid.h>
void inil_grid(g, ng, gmin, gmax)void inia_grid(g, na, a)void inip_grid(g,
ng, fmin, fmax, f)
int index_grid(g, x)real value_grid(g, i)
Grid *g;int
ng, na;real gmin, gmax, fmin, gmax, x, i;rproc f;

Description

The grid are a set of routines to aid in simple 1 dimensional gridding problems. The routines are written in C but in an object-oriented fashion as to isolate the user from the internal datastructure. The Grid can (and should) be treated as an opaque datastructure. All information should be obtained through interface routines.

iniX_grid is used to set up a grid. A grid can be monotonically increasing as well as decreasing. (X=l linear grid, X=a array defined grid, X=p procedure defined grid)

index_grid returns the (C) index onto the grid, and is a number in the range 0 to N-1. -1 is returned if the requested value is outside the grid. Both edges of the grid are considered part of the grid, where rounding occurs towards the gmin (’left’) value (see floor(3M) ). Only for the last grid-cell (the ’right’ grid cell, with index n-1) both edges are considered part of the grid-cell.

value_grid returns the physical value associated with the grid, allowing for a real valued grid index value i which is in the range 0 to N (0 being the ’left’ edge, and N the ’right’ edge). 0.5 means the center of the first grid cell etc. Index values outside the normal 0..N range return a legal value for a linear grid only, and cause a fatal error for an array lookup (or perhaps we will extrapolate using the two edge points).

Moment Structure

A simple data structure (referred to as Grid in the above SYNOPSIS) is used to communicate between different routines:
typedef struct { 
    int mode;
    int n;
    bool up;
    real *g;
    real gmin, gmax;
    rproc f;
} Grid;
from the standard include file grid.h.

Bugs

Array and Procedure gridding don’t work.

See Also

moment(3NEMO) , floor(3M)

Author

Peter Teuben

Files


~/src/kernel/misc    grid.c

Update History


30-oct-93    Created       PJT


Table of Contents