#include <cx/Lookup.h>cxLookup *cxLookupCreate(cxLattice *lattice, cxLookupType interp)
integer function cxLookupCreate(lattice, interp) integer lattice, interp
The lookup table is built to perform interpolation according to the method specified by the variable interp. Setting interp = cx_lookup_nearest specifies nearest neighbor interpolation, while setting interp = cx_lookup_linear specifies linear interpolation.
The returned lookup table contains a reference to the lattice and to other auxiliary information that speeds up lookup operations. The shared memory reference count of the lattice is incremented by one to indicate its use in the lookup table structure (defined in the file cx/Lookup.h).
For curvilinear lattices with nCoordVar > nDim (scattered data) NAG routines are used for interpolation within the bounding box, while an error exit is returned outside the bounding box. Strictly speaking this is a combination of interpolation (for points inside the lattice domain) and extrapolation (for points outside the lattice domain but inside the bounding box). The nearest neighbor method is faster, but less accurate than, the linear method.
For curvilinear lattices with nDim = nCoordVar (structured meshes), as well as all uniform and perimeter lattices a different interpolation method is employed. Curvilinear lattices are preprocessed using a k-D tree for faster point location in the lattice. In this case, performing lookups on a uniform or perimeter lattice is substantially faster than on a curvilinear lattice. There is little difference in execution speed between nearest neighbor and linear interpolation.
Lookup tables are used to preprocess colormap information for later color lookup, for example in the Contour module. They are also used in the Interpolate and PickLat modules for data interpolation, and in modules that calculate particle trajectories, such as NAGAdvectSimple, NAGAdvectAnimate, and LatSmoke.