Ticket #3724: m4ri_hash.patch
| File m4ri_hash.patch, 2.1 kB (added by malb, 5 months ago) |
|---|
-
a/c_lib/include/pb_wrap.h
old new 6 6 7 7 // M4RI 8 8 #define PACKED 1 9 #include "M4RI/packedmatrix.h" 10 #include "M4RI/grayflex.h" 9 #include "M4RI/m4ri.h" 11 10 12 11 #include <sstream> 13 12 #include <vector> -
a/sage/matrix/matrix_mod2_dense.pyx
old new 281 281 {[0 1 0] 282 282 [0 1 1] 283 283 [0 0 0]: 0} 284 sage: A = matrix(GF(2),2,2) 285 sage: A.set_immutable() 286 sage: hex(hash(A)) 287 '0xdeadbeed' 284 288 285 289 TEST: 286 290 sage: A = matrix(GF(2),2,0) … … 288 292 sage: hash(A) 289 293 0 290 294 """ 291 return self._hash() 295 cdef unsigned long _hash = 0xDEADBEEF 296 cdef unsigned long counter = 0 297 cdef unsigned long i, j, truerow 298 cdef word mask = 1 299 mask = ~((mask<<(RADIX - self._ncols%RADIX))-1) 300 301 if self._nrows == 0 or self._ncols == 0: 302 return 0 303 304 for i from 0 <= i < self._entries.nrows: 305 truerow = self._entries.rowswap[i] 306 for j from 0 <= j < self._entries.width - 1: 307 _hash ^= self._entries.values[truerow + j] 308 counter += 1 309 _hash ^= self._entries.values[truerow + j] & mask 310 counter += 1 311 312 _hash = _hash ^ counter 313 314 if _hash == -1: 315 return -2 316 return _hash 292 317 293 318 cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value): 294 319 mzd_write_bit(self._entries, i, j, int(value))