#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;
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).
typedef struct { int mode; int n; bool up; real *g; real gmin, gmax; rproc f; } Grid;from the standard include file grid.h.
~/src/kernel/misc grid.c
30-oct-93 Created PJT