Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 927 Bytes

count.md

File metadata and controls

62 lines (40 loc) · 927 Bytes

count

Count the set bits of every element.

API

Numeric.bit.count(value)

Counts the active bits in each nested entry.

  • Parameters:
    • value: Scalar, vector, or matrix values to inspect
  • Returns: Bit counts matching the input nesting shape
  • NumPy: Equivalent to np.bitwise_count.

Examples

Count the bits of a vector

import Numeric from '@neabyte/numerix'

const counts = Numeric.bit.count([7, 8])

console.log(counts)
// [3,1]

Count the bits of a single value

import Numeric from '@neabyte/numerix'

const count = Numeric.bit.count(7)

console.log(count)
// 3

Count the bits of a matrix

import Numeric from '@neabyte/numerix'

const counts = Numeric.bit.count([[7, 8]])

console.log(counts)
// [[3,1]]

Count the bits of a zero value

import Numeric from '@neabyte/numerix'

const count = Numeric.bit.count(0)

console.log(count)
// 0