Skip to contents

Element-wise population count (number of set bits).

Usage

prim_popcnt(x)

Arguments

x

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

Value

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

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to hlo_popcnt(), specified under popcnt.

See also

Examples

# the set bits are counted, at the input's own integer data type
x <- nv_array(c(7L, 3L, 15L))
prim_popcnt(x)
#> AnvlArray
#>  3
#>  2
#>  4
#> [ CPUi32{3} ]