Skip to contents

Negates an array element-wise. You can also use the unary - operator.

Usage

nv_negate(x)

Arguments

x

(arrayish)
One input. Can be any 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_negate() for the underlying primitive.

Examples

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

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