mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 18:15:29 +01:00
create uniform hash interface using hash_internal
This commit is contained in:
parent
920bc1f28d
commit
5810eeb4ae
@ -242,19 +242,18 @@ evaluate(f::Automorphism) = f(domain(parent(f)))
|
||||
|
||||
const HASHINGCONST = 0x7d28276b01874b19 # hash(Automorphism)
|
||||
|
||||
hash(s::AutSymbol, h::UInt) = hash(s.id, hash(s.pow, hash(:AutSymbol, h)))
|
||||
hash(s::AutSymbol, h::UInt) = hash(s.id, hash(s.pow, hash(AutSymbol, h)))
|
||||
|
||||
function hash(g::Automorphism{N}, images, h::UInt=HASHINGCONST) where N
|
||||
return hash(images, hash(parent(g), hash(Automorphism{N}, h)))
|
||||
function hash_internal(g::Automorphism, images = freereduce!.(evaluate(g)),
|
||||
h::UInt = HASHINGCONST)
|
||||
return hash(images, hash(parent(g), h))
|
||||
end
|
||||
|
||||
function hash(g::Automorphism, h::UInt)
|
||||
if g.modified
|
||||
g_im = reduce!.(evaluate(g))
|
||||
g.savedhash = hash(g, g_im)
|
||||
g.modified = false
|
||||
end
|
||||
return xor(g.savedhash, h)
|
||||
function compute_images(g::Automorphism)
|
||||
images = reduce!.(evaluate(g))
|
||||
g.savedhash = hash_internal(g, images)
|
||||
unsetmodified!(g)
|
||||
return images
|
||||
end
|
||||
|
||||
function (==)(g::Automorphism{N}, h::Automorphism{N}) where N
|
||||
|
@ -95,8 +95,6 @@ end
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
hash(s::FPSymbol, h::UInt) = hash(s.id, hash(s.pow, hash(FPSymbol, h)))
|
||||
|
||||
change_pow(s::FPSymbol, n::Int) = FPSymbol(s.id, n)
|
||||
|
||||
length(s::FPSymbol) = abs(s.pow)
|
||||
|
@ -80,8 +80,6 @@ end
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
hash(s::FreeSymbol, h::UInt) = hash(s.id, hash(s.pow, hash(FreeSymbol, h)))
|
||||
|
||||
change_pow(s::FreeSymbol, n::Int) = FreeSymbol(s.id, n)
|
||||
|
||||
length(s::FreeSymbol) = abs(s.pow)
|
||||
|
@ -101,8 +101,16 @@ convert(::Type{GroupWord{T}}, s::T) where {T<:GSymbol} = GroupWord{T}(T[s])
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
function hash_internal(W::GWord)
|
||||
reduce!(W)
|
||||
return hash(syllables(W), hash(typeof(W), hash(parent(W))))
|
||||
end
|
||||
|
||||
function hash(W::GWord, h::UInt)
|
||||
W.modified && reduce!(W)
|
||||
if ismodified(W)
|
||||
W.savedhash = hash_internal(W)
|
||||
unsetmodified!(W)
|
||||
end
|
||||
return xor(W.savedhash, h)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user