interpolateInterpolate in an ordered list of tuples |
|
This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The output y is the interpolated value given a list of tuples (tuples = { {x1,y1}, {x2,y2}, ...}) and an index value jlo (default = 1) to guide the search. The function will also return the actual index value jsav used for the interpolation.
Functions.interpolate(x, tuples); // jlo = 1 Functions.interpolate(x, tuples, jlo);
The index value jlo is used to guide the further procedure: If jlo == 1 then we assume that we are starting out a fresh search und accordingly locate() is used to come up with the correct index value to use for rawInterpolate().
If jlo > 1, then we assume to already have searched in the list of tuples and we can use the last index value to speed up the search; accordingly hunt will be used to find the new index value.
interpolate(1.5, {{0,1},{1,2}, {2,4},{3,5}}); // (3.0, 2)
| x |
Type: Real Description: Value to locate in a list |
|---|---|
| tuples |
Type: Real[:,2] Description: Ordered list of values |
| jlo |
Default Value: 1 Type: Integer Description: Index start value for the search |
| y |
Type: Real Description: Interpolated value |
|---|---|
| jsav |
Type: Integer Description: Index value used for the current interpolation |