Search code examples
c++bitwise-operatorsinformation-retrievaladjacency-matrixboolean-search

Bitwise operation on a dynamic data structure


I am implementing a simple document indexer for information retrieval. Now I need to implement an incidence matrix, that should be able to be extended dynamically (not satisfied with just a static array or smth).

And to make boolean search possible I have to be able to perform bitwise operations on the rows of the matrix. However, I have not come up with a fast solution. The question is data structure for each row of the matrix.

If it were just a std::vector<bool>, is it possible to do FAST bitwise operations on it? Or is there any other data structure, like BitArray from C#, applicable in the situation?


Solution

  • If FAST is your goal, look into using largest int available on your system (likely - uint64_t) and do a simple bitwise operations on that. If your matrix is wider that 64 - use an std::array of those. Then check if your compiler generates SIMD instructions from your code. If not - consider using intrinsics https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#