discodop.bit

Functions for working with bitvectors.

NB: most functions are in bit.pxd to facilitate function inlining.

Functions

bitcount(uint64_t vec) Return number of set bits (1s).
fanout(arg) Return number of contiguous components in bit vector (gaps plus one).
pyintbitcount(a) Return number of set bits (1s) in a Python integer.
pyintnextset(a, int pos) Return index of first set bit, starting from pos.
test()
discodop.bit.bitcount(uint64_t vec) → int

Return number of set bits (1s).

>>> bitcount(0b0011101)
4
discodop.bit.fanout(arg) → int

Return number of contiguous components in bit vector (gaps plus one).

>>> fanout(0b011011011)
3
discodop.bit.pyintbitcount(a)

Return number of set bits (1s) in a Python integer.

>>> pyintbitcount(0b0011101)
4
discodop.bit.pyintnextset(a, int pos) → int

Return index of first set bit, starting from pos.

>>> pyintnextset(0b001101, 1)
2