# HG changeset patch
# User Nicolas M. Thiery <nthiery@users.sf.net>
# Date 1300298728 3600
# Node ID d966548caf0cc6d02d29eb98edb125828892d746
# Parent 04444e4387f8b981c1e1f6f3bcbe00383fc8674c
The hash function for dense matrices suffers from many collisions with permutation matrices
diff git a/sage/matrix/matrix_dense.pyx b/sage/matrix/matrix_dense.pyx
a

b

cdef class Matrix_dense(matrix.Matrix): 
69  69  if not self._mutability._is_immutable: 
70  70  raise TypeError, "mutable matrices are unhashable" 
71  71  
72   v = self._list() 
73   cdef Py_ssize_t i 
74   cdef long h = 0 
 72  # v = self._list() 
 73  # cdef Py_ssize_t i 
 74  # cdef long h = 0 
75  75  
76   for i from 0 <= i < len(v): 
77   h = h ^ (i * hash(v[i])) 
 76  # for i from 0 <= i < len(v): 
 77  # h = h ^ (i * hash(v[i])) 
78  78  
79   if h == 1: 
80   h = 2 
 79  # if h == 1: 
 80  # h = 2 
81  81  
 82  h = hash(tuple(self._list())) 
82  83  self.cache('hash', h) 
83  84  return h 
84  85  