Skip to contents

Element-wise check if values are infinite (Inf or -Inf). You can also use is.infinite(). Only a float holds an infinity, so the answer for any other data type is all FALSE and is built as a constant rather than computed.

Usage

nv_is_infinite(x)

Arguments

x

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

Value

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

Examples

# the result is boolean, whatever float data type the input has
x <- nv_array(c(1, NaN, Inf, -Inf, 0))
nv_is_infinite(x)
#> AnvlArray
#>  0
#>  0
#>  1
#>  1
#>  0
#> [ CPUbool{5} ] 

# all FALSE for an integer input, which has no infinity
nv_is_infinite(nv_array(1:3))
#> AnvlArray
#>  0
#>  0
#>  0
#> [ CPUbool{3} ] 

# an R value materializes at its default data type before the test
nv_is_infinite(1)
#> AnvlArray
#>  0
#> [ CPUbool{} ]