cupyx.scatter_min#
- cupyx.scatter_min(a, slices, value)[source]#
Stores a minimum value of elements specified by indices to an array.
It stores the minimum value of elements in
value
array indexed byslices
toa
. If all of the indices target different locations, the operation ofscatter_min()
is equivalent toa[slices] = cupy.minimum(a[slices], value)
. If there are multiple elements targeting the same location,scatter_min()
stores the minimum of all of these values to the given index ofa
, the initial element ofa
is also taken in account.Note that just like an array indexing, negative indices are interpreted as counting from the end of an array.
Also note that
scatter_min()
behaves identically tonumpy.minimum.at()
.Example
>>> import numpy >>> import cupy >>> a = cupy.zeros((6,), dtype=numpy.float32) >>> i = cupy.array([1, 0, 1, 2]) >>> v = cupy.array([1., 2., 3., -1.]) >>> cupyx.scatter_min(a, i, v); >>> a array([ 0., 0., -1., 0., 0., 0.], dtype=float32)
- Parameters:
a (ndarray) – An array to store the results.
slices – It is integer, slices, ellipsis, numpy.newaxis, integer array-like, boolean array-like or tuple of them. It works for slices used for
cupy.ndarray.__getitem__()
andcupy.ndarray.__setitem__()
.v (array-like) – An array used for reference.