Skip to contents

Returns the index of the minimum value along a single axis. Ties are broken by returning the smallest index.

Usage

prim_argmin(x, axis, drop = TRUE)

Arguments

x

(arrayish)
Arrayish value of any data type.

axis

(integer(1))
Axis along which to find the index of the maximum. Negative values count from the end, i.e. -1 refers to the last axis.

drop

(logical(1))
If TRUE (default) the reduced axis is removed; if FALSE it is kept with size 1.

Value

arrayish of dtype i32
Same shape as x with axis removed (or set to 1 if drop = FALSE).

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to a variadic hlo_reduce() over (values, indices) with a (value < value | (value == value & idx < idx)) selector.

Examples

prim_argmin(nv_array(c(3, 1, 4, 1, 5)), axis = 1L)
#> AnvlArray
#>  2
#> [ CPUi32{} ]