mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 18:15:29 +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
|
end
|
||||||
|
|
||||||
function (==)(g::Automorphism{N}, h::Automorphism{N}) where N
|
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 ismodified(g)
|
||||||
if g.savedhash != h.savedhash
|
img = compute_images(g)
|
||||||
return false
|
img_c = true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# expensive:
|
if ismodified(h)
|
||||||
g_im = reduce!.(evaluate(g))
|
imh = compute_images(h)
|
||||||
h_im = reduce!.(evaluate(h))
|
imh_c = true
|
||||||
# cheap:
|
end
|
||||||
g.savedhash = hash(g, g_im)
|
|
||||||
g.modified = false
|
|
||||||
h.savedhash = hash(h, h_im)
|
|
||||||
h.modified = false
|
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user