dpnp.bitwise_count

dpnp.bitwise_count = <DPNPUnaryFunc 'bitwise_count'>

Computes the number of 1-bits in the absolute value of x.

For full documentation refer to numpy.bitwise_count.

Parameters:
x{dpnp.ndarray, usm_ndarray}

Input array, expected to have an integer data type.

out{None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional

Output array to populate. Array must have the correct shape and the expected data type. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

Default: None.

order{None, "C", "F", "A", "K"}, optional

Memory layout of the newly output array, if parameter out is None.

Default: "K".

Returns:
outdpnp.ndarray

The corresponding number of 1-bits in the input. Returns uint8 for all integer types.

Limitations

Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

Examples

>>> import dpnp as np
>>> a = np.array(1023)
>>> np.bitwise_count(a)
array(10, dtype=uint8)
>>> a = np.array([2**i - 1 for i in range(16)])
>>> np.bitwise_count(a)
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15],
      dtype=uint8)