Suppose I have a binary matrix of size m by n. Each row is n bits long. I would like to store this matrix as space efficiently as possible while still being able to quickly retrieve individual rows. In particular I'd like to be able to do bitwise operations on the rows after retrieving them. To do this I'm using the JavaScript TypedArray.
My attempt at a solution is the following:
To retrieve a specific row i:
rowLength.rowStartOffset = i*rowLength; rowEndOffset = (i+1)*rowLength-1 and slice the arrayThis works, but I wondered if there was a better way to do this. In particular is there a way to do bitwise operations without having to convert back into binary? (Currently I'm doing this by converting the integers into a binary string and then concatenating). Is there a method which does not use TypedArray?