New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hash of (dense) matrices #21316
Comments
comment:1
From
What is a good caching strategy? Simply |
comment:2
Non-cryptographic hashes don't have to be resilient to collision attacks, but should indeed give good hash value spread for the input space - which this implementation doesn't. I can confirm that this implementation causes massive performance degradation when matrices are used as dictionary keys, for instance. See tuple hash algorithm and explanations why XORing hash values doesn't perform very well. While the current implementation does try to 'save' itself from the disadvantages of XORing hash values by multiplying by the index, it still performs very poorly. I tried the solution dkrenn suggested and it does indeed work much better. |
Branch: u/dkrenn/hash-matrix |
Commit: |
Work Issues: adapt doctests |
New commits:
|
comment:6
Looks like major work was put into this issue in #19050, rendering this ticket a duplicate. |
comment:7
Duplicate of #10950. |
It took me only 4 guesses to find two matrices with the same hash:
This should not be that easy.
In particular (looking at the code in
sage.matrix.matric_dense
), the hash value does not depend on entry 1,1 of the matrix (multiplication by zero in the hash code):Component: misc
Work Issues: adapt doctests
Branch/Commit: u/dkrenn/hash-matrix @
1e1263f
Issue created by migration from https://trac.sagemath.org/ticket/21316
The text was updated successfully, but these errors were encountered: