Given a N-dimensional vector of small integers is there any simple way to map it with one-to-one correspondence to a large integer number?
Say, we have N=3 vector space. Can we represent a vector X=[(int16)x1,(int16)x2,(int16)x3] using an integer (int48)y? The obvious answer is “Yes, we can”. But the question is: “What is the fastest way to do this and its inverse operation?”
Will this new 1-dimensional space possess some very special useful properties?
Just to make this concrete, if you have a 3-dimensional vector of 8-bit numbers, like this:
then you can join them into a single (24-bit number) like so:
This number would, if printed using this statement:
produce the output
The reverse operation would look like this:
Of course this all depends on the size of the individual numbers in the vector and the length of the vector together not exceeding the size of an available integer type, otherwise you can’t represent the “packed” vector as a single number.