Bit counting


Data Structures

struct  zom_t
 Bit-parallel arithmetic on numbers 0, 1, more. More...

Functions

static unsigned naive_bitcount (unsigned w)
 Compute the number of ones in the binary representation of w.
static void init_bitcount (void)
 Initialise the array bitcount.
static unsigned bitcount (word_t w)
 Compute the number of ones in the binary representation of w.
static zom_t zom_add (zom_t x, zom_t y)
 Calculate x + y in zom_t.
static word_t zom_exactly_1 (zom_t x)
 Return a bit vector where a bit is set if the value is exactly 1.
static void word_clear (word_t *restrict array, size_t n)
 Zero an array of word_t.
static void zom_clear (zom_t *restrict array, size_t n)
 Zero an array of zom_t.

Variables

static bitcount_t bitcounts [1U<< BITCOUNT_BITS]
 A lookup table where precomputed bit counts are stored.


Function Documentation

static unsigned bitcount ( word_t  w  )  [inline, static]

Compute the number of ones in the binary representation of w.

Definition at line 387 of file types.c.

References BITCOUNT_BITS, bitcounts, and WORD_BITS.

Referenced by calculate_bounds_hapax(), and calculate_bounds_normal().

static void init_bitcount ( void   )  [static]

Initialise the array bitcount.

Definition at line 378 of file types.c.

References BITCOUNT_BITS, bitcounts, and naive_bitcount().

Referenced by main().

static unsigned naive_bitcount ( unsigned  w  )  [inline, static]

Compute the number of ones in the binary representation of w.

A naive algorithm which does not use the array bitcounts.

Definition at line 363 of file types.c.

Referenced by init_bitcount().

static void word_clear ( word_t *restrict  array,
size_t  n 
) [inline, static]

Zero an array of word_t.

Definition at line 448 of file types.c.

static zom_t zom_add ( zom_t  x,
zom_t  y 
) [inline, static]

Calculate x + y in zom_t.

Definition at line 432 of file types.c.

References zom_t::at_least_1, and zom_t::at_least_2.

Referenced by calculate_bounds_hapax().

static void zom_clear ( zom_t *restrict  array,
size_t  n 
) [inline, static]

Zero an array of zom_t.

Definition at line 457 of file types.c.

static word_t zom_exactly_1 ( zom_t  x  )  [inline, static]

Return a bit vector where a bit is set if the value is exactly 1.

Definition at line 441 of file types.c.

References zom_t::at_least_1, and zom_t::at_least_2.

Referenced by calculate_bounds_hapax().


Variable Documentation

bitcount_t bitcounts[1U<< BITCOUNT_BITS] [static]

A lookup table where precomputed bit counts are stored.

Definition at line 374 of file types.c.

Referenced by bitcount(), and init_bitcount().