Skip to contents

Reverses the order of elements along specified axes.

Usage

prim_reverse(x, axes)

Arguments

x

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

axes

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

Value

(arrayish)
Has the input's data type and shape.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_reverse(), specified under reverse.

See also

Examples

# the order along axis 1 is flipped
x <- nv_array(c(1, 2, 3, 4, 5))
prim_reverse(x, axes = 1L)
#> AnvlArray
#>  5
#>  4
#>  3
#>  2
#>  1
#> [ CPUf32{5} ]