I am representing map ( matrix rows x columns ) with bits using bitset from stl or dynamic_bitset<> from boost ( I can use whatever I want ). I need to get submatrix of that matrix with smaller size( for example
a(2,2) a(2,3) a(3,2) a(3,3) there is size 2 ). Is there any efficient structure for representing matrix with bits and getting submatrix from startindex and length without iteration ?
I am representing map ( matrix rows x columns ) with bits using bitset
Share
It is possible to efficiently share data between matrices and submatrices. The trick is to track three variables in your class.
The
dataneeds to be ashared_ptrlike structure so that the underlying data can be destroyed once you are done with it.startwill be a pointer into the data referenced bydata,row_stridetells you how far to move to get to the next row.Additional things you might like to track are
Here’s how this might look for a non-bit based approach (I’ve omitted much .. but hopefully you get the gist).
Making this work for a bit based version would mean changing the
MatrixDatato hold one of the bot based structures, changingstartto be an index into the structure and changing youroperator()to access the data correctly.