Skip to contents

Element-wise absolute value. You can also use abs().

Usage

nv_abs(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.

See also

prim_abs() for the underlying primitive.

Examples

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

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