Skip to contents

Element-wise sign.

Usage

prim_sign(x)

Arguments

x

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

Value

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

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to hlo_sign(), specified under sign.

See also

Examples

# the input's data type carries through
x <- nv_array(c(-3, 0, 5))
prim_sign(x)
#> AnvlArray
#>  -1
#>   0
#>   1
#> [ CPUf32{3} ] 

# an R value materializes at its default data type
prim_sign(-3)
#> AnvlArray
#>  -1
#> [ CPUf32{} ]