#NEWLINE# @ jit ( nopython = True ) #NEWLINE# def searchsorted( a , v ) : #NEWLINE# #INDENT# "\n    Custom version of np.searchsorted. Return the largest index `i` such\n    that `a[i-1] <= v < a[i]` (for `i = 0`, `v < a[0]`); if `v[n-1] <=\n    v`, return `n`, where `n = len(a)`.\n\n    Parameters\n    ----------\n    a : ndarray(float, ndim=1)\n        Input array. Must be sorted in ascending order.\n\n    v : scalar(float)\n        Value to be compared with elements of `a`.\n\n    Returns\n    -------\n    scalar(int)\n        Largest index `i` such that `a[i-1] <= v < a[i]`, or len(a) if\n        no such index exists.\n\n    Notes\n    -----\n    This routine is jit-complied if the module Numba is vailable; if\n    not, it is an alias of np.searchsorted(a, v, side='right').\n\n    Examples\n    --------\n    >>> a = np.array([0.2, 0.4, 1.0])\n    >>> searchsorted(a, 0.1)\n    0\n    >>> searchsorted(a, 0.4)\n    2\n    >>> searchsorted(a, 2)\n    3\n\n    " #NEWLINE# lo = ( - 1 ) #NEWLINE# hi = len ( a ) #NEWLINE# while ( lo < ( hi - 1 ) ) : #NEWLINE# #INDENT# m = ( ( lo + hi ) // 2 ) #NEWLINE# if ( v < a [ v ] ) : #NEWLINE# #INDENT# hi = m #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lo = m #NEWLINE# #UNINDENT# #UNINDENT# return hi