Skip to contents

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

Usage

nv_argmin(operand, dim = NULL, drop = TRUE, nan_rm = FALSE)

Arguments

operand

(arrayish)
Operand.

dim

(integer(1) | NULL)
Dimension along which to find the index. If NULL (default), uses the last dimension.

drop

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

nan_rm

(logical(1))
How to handle NaN values in floating-point inputs. If FALSE (default), NaN propagates. If TRUE, NaN values are skipped.

Value

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

NaN handling

With nan_rm = FALSE (default), if any entry along the reduced axis is NaN, the returned index points at the first such NaN. With nan_rm = TRUE, NaN entries are skipped.

Examples

nv_argmin(nv_array(c(3, 1, 4, 1, 5, 9, 2, 6)))
#> AnvlArray
#>  2
#> [ CPUi32{} ] 
nv_argmin(nv_array(c(2, NaN, 1, 3)))
#> AnvlArray
#>  2
#> [ CPUi32{} ] 
nv_argmin(nv_array(c(2, NaN, 1, 3)), nan_rm = TRUE)
#> AnvlArray
#>  3
#> [ CPUi32{} ]