mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 02:05:30 +01:00
fast equality for Automorphisms
This commit is contained in:
parent
8248039d63
commit
99d5bc2f8c
@ -249,24 +249,29 @@ function compute_images(g::Automorphism)
|
||||
end
|
||||
|
||||
function (==)(g::Automorphism{N}, h::Automorphism{N}) where N
|
||||
parent(g) == parent(h) || return false
|
||||
img_c, imh_c = false, false
|
||||
|
||||
if !g.modified && !h.modified
|
||||
if g.savedhash != h.savedhash
|
||||
return false
|
||||
end
|
||||
if ismodified(g)
|
||||
img = compute_images(g)
|
||||
img_c = true
|
||||
end
|
||||
|
||||
# expensive:
|
||||
g_im = reduce!.(evaluate(g))
|
||||
h_im = reduce!.(evaluate(h))
|
||||
# cheap:
|
||||
g.savedhash = hash(g, g_im)
|
||||
g.modified = false
|
||||
h.savedhash = hash(h, h_im)
|
||||
h.modified = false
|
||||
if ismodified(h)
|
||||
imh = compute_images(h)
|
||||
imh_c = true
|
||||
end
|
||||
|
||||
return g_im == h_im
|
||||
@assert !ismodified(g) && !ismodified(h)
|
||||
# cheap
|
||||
hash(g) != hash(h) && return false # hashes differ, so images must have differed as well
|
||||
# equal elements, or possibly hash conflict
|
||||
if !img_c
|
||||
img = compute_images(g)
|
||||
end
|
||||
if !imh_c
|
||||
imh = compute_images(h)
|
||||
end
|
||||
return img == imh
|
||||
end
|
||||
|
||||
###############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user