id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
12290 Fix the hash of matrix spaces and improve its performance Simon King Jason Grout William Stein "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__())
}}}
__Apply__
[attachment:trac12290_unique_matrix_space.patch]" defect closed critical sage-5.0 linear algebra fixed hash matrix space unique parent sage-5.0.beta9 Simon King David Loeffler N/A #11900