How to associate a unique integer to a matrix with integer elements in $[-1 , 100]$

135 Views Asked by At

I have a $n \times m$ matrix $A$ with entries $A_{i,j} \in [0 , 100] \cap \mathbb{Z}$. with a great likelihood of 0

I would like to represent this matrix by the smallest integer value possible.

What would be the best way to do so?

EDIT: The bottom line is to represent matrices into an integer so that they could be "easily" compared by a computer to find duplicate.

Thanks for your help.

1

There are 1 best solutions below

0
On

The practical answer is to hash the file. Unless you have a lot of matrices, the chance of a collision is very small. You just have to have a well defined way of representing the matrix, always with the same number of spaces between the entries for example. Then you can compare the hashes. If you insist, you can go back to the original files whenever the hashes match and do a real compare to avoid collisions.