Skip to contents

Finds the minimum of array elements along the specified axes.

Usage

prim_reduce_min(x, axes, drop = TRUE)

Arguments

x

(arrayish)
One input. Can be any data type. An R value materializes at its default data type.

axes

(integer())
Axes to reduce over. Negative values count from the end, i.e. -1 refers to the last axis.

drop

(logical(1))
Whether to drop the reduced axes: removed from the output shape if TRUE, set to 1 if FALSE.

Value

(arrayish)
Has the input's data type. The shape is the input's with the reduced axes removed (drop = TRUE) or set to 1 (drop = FALSE).

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_reduce(), specified under reduce. The reducer is hlo_minimum().

See also

Examples

x <- nv_matrix(1:6, nrow = 2)
# reducing axis 1 removes it from the shape, and the data type is kept
prim_reduce_min(x, axes = 1L)
#> AnvlArray
#>  1
#>  3
#>  5
#> [ CPUi32{3} ] 

# drop = FALSE keeps the reduced axis at size 1 instead
prim_reduce_min(x, axes = 1L, drop = FALSE)
#> AnvlArray
#>  1 3 5
#> [ CPUi32{1,3} ] 

# reducing every axis gives a scalar
prim_reduce_min(x, axes = c(1L, 2L))
#> AnvlArray
#>  1
#> [ CPUi32{} ]