population_count#
- class brainunit.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 aQuantity, 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)