Skip to contents

Element-wise check if values are finite (not Inf, -Inf, or NaN).

Usage

prim_is_finite(x)

Arguments

x

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

Value

(arrayish)
Has the same shape as the input and boolean data type.

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to hlo_is_finite(), specified under is_finite.

See also

Examples

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

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