© 2010-2012 Anna Bigatti
GNU Free Documentation License, Version 1.2

CoCoALib Documentation Index



User documentation

Class for representing square free monomials, or subsets of integers.

This is quite technical and useful only when efficiency is important.

Similar to a C++ bitset except that its size does not need to be fixed at compile time (hence the adjective dynamic).


Let n be an integer, pp a PPMonoidElem, b a DynamicBitset


Let DB1 and DB2 be two (const) values of type DynamicBitset

Member functions

Additionally, let DB be a non-const value of type DynamicBitset.

These two do not check that the index is valid:

output options

Default printing style is clean, i.e. as an STL bitset of the same size. Printing style can be changed by setting the variable DynamicBitset::ourOutputStyle Example with a 66-bit DynamicBitset on a 64-bit machine:

DynamicBitset::clean 0000000000000000000000000000000011
DynamicBitset::WithSeparators 00-00000000.00000000.00000000.00000011
DynamicBitset::AsRevVecOfLong [0, 3]

(see ex-DynamicBitset1.C).

Member functions

Maintainer documentation

Member fields (private)

std::vector<BitBlock> myVec;
unsigned long mySizeValue;

The long constant DynamicBitset::ourNumBitsInBlock stores number of bits contained in an unsigned long (normally 32 or 64).

So a DynamicBitset stores a STL vector of STL bitsets of (constant) size ourNumBitsInBlock called myVec. The field mySizeValue is the number of bits we intend to use. (e.g. in a 32 bit machine a DynamicBitset of size 60 is stored as a vector with 2 BitBlocks and will have 4 unused bits)

     enum OutputStyle {clean, AsRevVecOfLong, WithSeparators};

Member functions (private)

Bugs, shortcomings and other ideas


This class is needed because C++ bitset length has to be fixed at compile time. There is a class in boost named dynamic_bitset: if/when we decide CoCoALib inlude boost DynamicBitset will just call the boost implementation.


DynamicBitsets, unlike boost's dynamic_bitsets, are not stretchable: the resize function is private. They are used to represent square-free power-products, therefore changing size does not make sense. But there is no technical reason to forbid it, so we might make it available.

Main changes