Function vector_bsearch_inc (o2scl)¶
-
template<class vec_t, class data_t>
size_t o2scl::vector_bsearch_inc(const data_t x0, const vec_t &x, size_t lo, size_t hi)¶ Binary search a part of an increasing vector for
x0
.This function performs a binary search of between
x[lo]
andx[hi]
. It returnslo
ifx0
<x[lo]
i
ifx[i]
<=x0
<x[i+2]
forlo
<=i
<hi
hi-1
ifx0
>=[hi-1]
This function is designed to find the interval containing
x0
, not the index of the element closest to x0. To perform the latter operation, you can use vector_lookup().The element at
x[hi]
is never referenced by this function. The parameterhi
can be either the index of the last element (e.g.n-1
for a vector of sizen
with starting index0
), or the index of one element (e.g.n
for a vector of sizen
and a starting index0
) for a depending on whether or not the user wants to allow the function to return the index of the last element.This function operates in the same way as
gsl_interp_bsearch()
.The operation of this function is undefined if the data is not strictly monotonic, i.e. if some of the data elements are equal.
This function will call the error handler if
lo
is greater thanhi
.