cupy.searchsorted — CuPy 13.4.1 documentation (original) (raw)
cupy.searchsorted(a, v, side='left', sorter=None)[source]#
Finds indices where elements should be inserted to maintain order.
Find the indices into a sorted array a
such that, if the corresponding elements in v
were inserted before the indices, the order of a
would be preserved.
Parameters:
- a (cupy.ndarray) – Input array. If
sorter
isNone
, then it must be sorted in ascending order, otherwisesorter
must be an array of indices that sort it. - v (cupy.ndarray) – Values to insert into
a
. - side – {‘left’, ‘right’} If
left
, return the index of the first suitable location found Ifright
, return the last such index. If there is no suitable index, return either 0 or length ofa
. - sorter – 1-D array_like Optional array of integer indices that sort array
a
into ascending order. They are typically the result ofargsort().
Returns:
Array of insertion points with the same shape as v
.
Return type:
Note
When a is not in ascending order, behavior is undefined.