This is a utility function which searches an monotonic sequence (with increasing or decreasing elements) using the bisection method and returns the relative position within the sequence.
We offer this method as an auxiliary method since though sorting
algorithms are strictly speaking not part of Interpolation or
Extrapolation theory these methods are often required such methods. Here we
implement what is known as the bisection method which will find the
right place in about log2 n tries, where n
is the number of elements in the monotonic sequence. To summaries the bisection
algorithm is an ideal sorting algorithm to use here and can only
marginally be improved in particular cases and most importantly it is
sufficiently fast in all practical instances which we have encountered.
This method attempts to bracket the valueBeingOrdered
parameter between two consecutive elements of the array and return
the lower bound. Several special cases are treated separately as follows:
InterpolationException is thrown.-1 if the value should be
ordered before the first element or the position of the last element
if the value should be ordered after the last element.| Exception Type | Condition |
|---|---|
| InterpolationException | Thrown when the array is null. |
Interpolation Class | WebCab.Libraries.Math.Interpolation Namespace