#12290: Fix the hash of matrix spaces and improve its performance
------------------------------+---------------------------------------------
Reporter: SimonKing | Owner: jason, was
Type: defect | Status: new
Priority: critical | Milestone: sage-5.0
Component: linear algebra | Keywords: hash matrix space
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
------------------------------+---------------------------------------------
The central assumptions for any hash function is: If two objects are equal
then they must have the same hash. That assumption is violated for matrix
spaces:
{{{
sage: M = MatrixSpace(ZZ, 10)
sage: N = MatrixSpace(ZZ, 10,sparse=True)
sage: N
Full MatrixSpace of 10 by 10 sparse matrices over Integer Ring
sage: M
Full MatrixSpace of 10 by 10 dense matrices over Integer Ring
sage: M == N
True
sage: hash(M)==hash(N)
False
}}}
That has to be fixed. Moreover, the hash of matrix spaces is rather
sluggish and should thus be improved speed-wise:
{{{
sage: %timeit hash(M)
625 loops, best of 3: 13.8 µs per loop
}}}
The root of both evils is the generic `__hash__` method inherited from
`SageObject`:
{{{
def __hash__(self):
return hash(self.__repr__())
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12290>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.