Skip to contents

Permutes the axes of an array.

Usage

prim_transpose(x, permutation)

Arguments

x

(arrayish)
Arrayish value of any data type.

permutation

(integer())
Specifies the new ordering of axes. Must be a permutation of seq_len(naxes(x)), the axis indices of x. Negative values count from the end, i.e. -1 refers to the last axis.

Value

arrayish
Has the same data type as the input and shape nv_shape(x)[permutation]. It is ambiguous if the input is ambiguous.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_transpose().

See also

Examples

x <- nv_matrix(1:6, nrow = 2)
prim_transpose(x, permutation = c(2L, 1L))
#> AnvlArray
#>  1 2
#>  3 4
#>  5 6
#> [ CPUi32{3,2} ]