The VALUE_LOCATE function finds the intervals within a given monotonic vector that brackets a given set of one or more search values. This function is useful for interpolation and table-lookup, and is an adaptation of the locate() routine in Numerical Recipes. VALUE_LOCATE uses the bisection method to locate the interval.
Result = VALUE_LOCATE ( Vector, Value [, /L64 ] )
Each return value, Result [i], is an index, j, into Vector, corresponding to the interval into which the given Value [i] falls. The returned values are in the range -1 £ j £ N-1, where N is the number of elements in the input vector.
If Vector is monotonically increasing, the result j is:
if j = -1 Value [i] < Vector 
if 0 £ j < N-1 Vector [j] £ Value [i] < Vector [j+1]
if j = N-1 Vector [N-1] £ Value [i]
If Vector is monotonically decreasing
if j = -1 Vector  £ Value [i]
if 0 £ j < N-1 Vector [j+1] £ Value [i] < Vector [j]
if j = N-1 Value [i] < Vector [N-1]
A vector of monotonically increasing or decreasing values. Vector may be of type string, or any numeric type except complex, and may not contain the value NaN (not-a-number).
The value for which the location of the intervals is to be computed. Value may be either a scalar or an array. The return value will contain the same number of elements as this parameter.
By default, the result of VALUE_LOCATE is 32-bit integer when possible, and 64-bit integer if the number of elements being processed requires it. Set L64 to force 64-bit integers to be returned in all cases.
; Define a vector of values. vec = [2,5,8,10] ; Compute location of other values within that vector. loc = VALUE_LOCATE(vec, [0,3,5,6,12]) PRINT, loc
-1 0 1 1 3