These methods operate on tables (arrays) of data.
Given an array of monotonically changing values xtab and a value of x, calculates the position in the table corresponding to x. Also takes an optional initial guess (e.g. the previous value) to speed the search if possible. This value is ignored if negative or greater than the table size-1.
Interface:
int tabpos( const double x, // ordinate const Array& xtab, // table, increasing const int lastpos = -1 // last position, if known )
Example:
#include... Array t; double x; ... int pos = tabpos(x,t);
Interface:
double lininterp( const double x, // ordinate const ArrayN.B. The arrays must be the same size.& xtab, // array of x values, increasing const Array & ftab, // array of f(x) values const int lastpos = -1 // last position, if known )
Example:
#include... Array xtab,ftab; double x; ... double f = lininterp(x,xtab,ftab);
Interface:
double polyinterp( const double x, // ordinate const ArrayN.B. The arrays must be the same size.& xtab, // array of x values, increasing const Array & ftab, // array of f(x) values const int order, // order of interpolating polynomial const int lastpos = -1 // last position, if known )
Example:
#include... Array xtab,ftab; double x; int order = 2; // quadratic ... double f = polyinterp(x,xtab,ftab,order);