population_count

Contents

population_count#

class saiunit.lax.population_count(x)#

Elementwise popcount: count the number of set bits in each element.

Parameters:

x (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Input integer array. If a Quantity, the unit is stripped before computing.

Returns:

result – The number of set bits in each element. Always unitless.

Return type:

Array

Examples

>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> import jax.numpy as jnp
>>> x = jnp.array([1, 3, 7])
>>> sulax.population_count(x)
Array([1, 2, 3], dtype=int32)