Skip to contents

Converts the elements of an array to a different data type. Returns the input unchanged if it already has the target type.

Usage

nv_convert(operand, dtype)

Arguments

operand

(arrayish)
Operand.

dtype

(character(1) | tengen::DataType)
Data type.

Value

arrayish
Has the given dtype and the same shape as operand.

See also

prim_convert() for the underlying primitive.

Examples

x <- nv_array(c(1L, 2L, 3L))
nv_convert(x, dtype = "f32")
#> AnvlArray
#>  1
#>  2
#>  3
#> [ CPUf32{3} ]