1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 14:35:28 +01:00

change hashing constant for reproducible hash of Automorphisms

This commit is contained in:
kalmarek 2018-07-30 15:00:02 +02:00
parent 192230c8d3
commit 0a20c5bb73

View File

@ -223,14 +223,14 @@ end
# #
############################################################################### ###############################################################################
const HASHINGCONST = 0x314a5215305f3ec1 # more or less random const HASHINGCONST = 0x7d28276b01874b19 # hash(Automorphism)
hash(s::AutSymbol, h::UInt) = hash(s.str, hash(s.pow, hash(:AutSymbol, h))) hash(s::AutSymbol, h::UInt) = hash(s.str, hash(s.pow, hash(:AutSymbol, h)))
function hash(g::Automorphism, h::UInt) function hash(g::Automorphism, h::UInt)
if g.modified if g.modified
g.savedhash = hash(reduce!.(g(domain(parent(g)))), g_im = reduce!.(g(domain(parent(g))))
hash(typeof(g), hash(parent(g), HASHINGCONST))) g.savedhash = hash(g_im, hash(typeof(g), hash(parent(g), HASHINGCONST)))
g.modified = false g.modified = false
end end
return xor(g.savedhash, h) return xor(g.savedhash, h)
@ -249,11 +249,9 @@ function (==)(g::Automorphism{N}, h::Automorphism{N}) where N
g_im = reduce!.(g(domain(parent(g)))) g_im = reduce!.(g(domain(parent(g))))
h_im = reduce!.(h(domain(parent(h)))) h_im = reduce!.(h(domain(parent(h))))
# cheap: # cheap:
g.savedhash = hash(g_im, g.savedhash = hash(g_im, hash(typeof(g), hash(parent(g), HASHINGCONST)))
hash(typeof(g), hash(parent(g), HASHINGCONST)))
g.modified = false g.modified = false
h.savedhash = hash(h_im, h.savedhash = hash(h_im, hash(typeof(h), hash(parent(h), HASHINGCONST)))
hash(typeof(h), hash(parent(h), HASHINGCONST)))
h.modified = false h.modified = false
return g_im == h_im return g_im == h_im