|<B>interval_searchB> value sequence [less_than [less_than_equal_to]]||
Given a value interval_search returns the location in the reference
to an array sequence where the value would fit. The default <
operator to compare the elements in sequence can be replaced by the
subroutine less_than which should return 1 if the first element passed
to less_than is less than the second. The default <= operator to
compare the elements in sequence can be replaced by the subroutine
less_than which should return 1 if the first element passed to
less_than is less than the second.
The values in sequence should already be sorted in numerically increasing order or in the order that would be produced by using the less_than subroutine.
Let N be the number of elements in referenced array sequence, then
interval_search returns these values:
If a reference is made to an empty array, then -1 is always returned.
If there is illegal input to interval_search, such as an improper number of arguments, then an empty list in list context, an undefined value in scalar context, or nothing in a void context is returned.
This subroutine is designed to be efficient in the common situation
that it is called repeatedly, with value taken from an increasing or
decreasing list of values. This will happen, e.g., when an irregular
waveform is interpolated to create a sequence with constant separation.
The first guess for the output is therefore taken to be the value
returned at the previous call and stored in the variable ilo. A first
check ascertains that ilo is less than the number of data points in
sequence. This is necessary since the present call may have nothing
to do with the previous call. Then, if
we set left = ilo and are done after just three comparisons. Otherwise,
we repeatedly double the difference
while also moving ilo and ihi in the direction of x, until
after which bisection is used to get, in addition,
Then left = ilo is returned.
Blair Zajac <email@example.com>.
Copyright (C) 1998-2005 Blair Zajac. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 244: =back doesnt take any parameters, but you said =back 4
|perl v5.20.3||MATH::INTERVALSEARCH (3)||2013-11-10|