I want to store a vector of integers (uint8) as (space-)efficiently as possible in MATLAB. So far, I am using arithenco to encode the vector:
bits = arithenco(z, counts);
The good thing is that it returns a vectors of bits. The bad thing is that the bits are stored in doubles. This means that the returned vector is about 64 times as large as the original uint8 vector, while the whole idea was to make the thing smaller.
So is there an easy (and runtime-efficient) way to encode those pseudo-bits so that I actually get a space improvement?
The only solution I've come up with yet is to use bitset to store all those bits in a vector of, say, uint32 again, but this seems to be cumbersome and not very fast as I will have to loop over the whole bits vector explicitly.
Note: I can not use the Java API for this, otherwise this would have been relatively easy.