Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High performance library for bit-wise operations?

Dealing with very large bool data set, try to use bit-wise operation to handle it, looking for some library that dealing with bit-set that can:

  1. Dynamic set, and can be passed by pointers or references.
  2. Read and write bitwisely.
  3. Count set bits and fast.

Obviously std::bitset's functionalities are too limited for that, any recommendations?

like image 888
user0002128 Avatar asked Jan 21 '13 03:01

user0002128


2 Answers

GMP provides low level bit functions on arbitrarily sized natural numbers. These are "low-level GMP functions, used to implement the high-level GMP functions, but also intended for time-critical user code."

These include mpn_popcount to count 1 bits, and mpn_copyi to extract sub-sequences.

like image 53
Doug Currie Avatar answered Sep 28 '22 09:09

Doug Currie


The BitMagic library might be your friend too.

like image 31
deltheil Avatar answered Sep 28 '22 08:09

deltheil