searchsorted#
- class saiunit.math.searchsorted(a, v, side='left', sorter=None, *, method='scan', **kwargs)#
Find indices where elements should be inserted to maintain order.
When both
aandvare Quantities,vis converted to the unit ofabefore searching.- Parameters:
a (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity) – Sorted input array.v (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity) – Values to insert intoa.side (
str) – If'left', the first suitable index is returned. Default is'left'.sorter (
Array|None) – Indices that sortainto ascending order.method (
str|None) – Algorithm selection. Default is'scan'.
- Returns:
indices – Insertion points with the same shape as
v.- Return type:
Array| saiunit.Quantity
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> a = jnp.array([1.0, 2.0, 3.0, 4.0]) >>> u.math.searchsorted(a, jnp.array([2.5])) Array([2], dtype=int32)