Sorting, Searching, and Counting¶

cupy.
sort
(a)[source]¶ Returns a sorted copy of an array with a stable sorting algorithm.
Parameters: a (cupy.ndarray) – Array to be sorted. Returns: Array of the same type and shape as a
.Return type: cupy.ndarray Note
For its implementation reason,
cupy.sort
currently supports only arrays with their rank of one and does not supportaxis
,kind
andorder
parameters thatnumpy.sort
does support.See also

cupy.
argmax
(a, axis=None, dtype=None, out=None, keepdims=False)[source]¶ Returns the indices of the maximum along an axis.
Parameters:  a (cupy.ndarray) – Array to take argmax.
 axis (int) – Along which axis to find the maximum.
a
is flattened by default.  dtype – Data type specifier.
 out (cupy.ndarray) – Output array.
 keepdims (bool) – If
True
, the axisaxis
is preserved as an axis of length one.
Returns: The indices of the maximum of
a
along an axis.Return type: See also

cupy.
argmin
(a, axis=None, dtype=None, out=None, keepdims=False)[source]¶ Returns the indices of the minimum along an axis.
Parameters:  a (cupy.ndarray) – Array to take argmin.
 axis (int) – Along which axis to find the minimum.
a
is flattened by default.  dtype – Data type specifier.
 out (cupy.ndarray) – Output array.
 keepdims (bool) – If
True
, the axisaxis
is preserved as an axis of length one.
Returns: The indices of the minimum of
a
along an axis.Return type: See also

cupy.
count_nonzero
(a, axis=None)[source]¶ Counts the number of nonzero values in the array.
Parameters:  a (cupy.ndarray) – The array for which to count nonzeros.
 axis (int or tuple, optional) – Axis or tuple of axes along which to
count nonzeros. Default is None, meaning that nonzeros will be
counted along a flattened version of
a
Returns:  Number of nonzero values in the array
along a given axis. Otherwise, the total number of nonzero values in the array is returned.
Return type: int or cupy.ndarray of int

cupy.
nonzero
(a)[source]¶ Return the indices of the elements that are nonzero.
Returns a tuple of arrays, one for each dimension of a, containing the indices of the nonzero elements in that dimension.
Parameters: a (cupy.ndarray) – array Returns: Indices of elements that are nonzero. Return type: tuple of arrays See also

cupy.
flatnonzero
(a)[source]¶ Return indices that are nonzero in the flattened version of a.
This is equivalent to a.ravel().nonzero()[0].
Parameters: a (cupy.ndarray) – input array Returns: Output array, containing the indices of the elements of a.ravel() that are nonzero. Return type: cupy.ndarray See also