1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-24 18:05:27 +01:00

rewrite simplify_perms!

This commit is contained in:
kalmarek 2018-03-28 12:20:03 +02:00
parent 6b0499005f
commit f493ed7283

View File

@ -329,42 +329,40 @@ function getperm(s::AutSymbol)
end end
end end
function simplify_perms!(W::Automorphism) function simplify_perms!(W::Automorphism{N}) where N
reduced = true reduced = true
for i in 1:length(W.symbols) - 1 to_delete = Int[]
current = W.symbols[i] for i in 1:length(W.symbols)-1
if isa(current.typ, PermAut) if isa(W.symbols[i].typ, PermAut) && isa(W.symbols[i+1].typ, PermAut)
next_s = W.symbols[i+1] reduced = false
if isa(next_s.typ, PermAut) c = W.symbols[i]
if current.pow != 1 n = W.symbols[i+1]
current = perm_autsymbol(perm(current), pow=current.pow) p = (getperm(c)*getperm(n)).d
end if p == PermutationGroup(N)()
push!(to_delete, i, i+1)
reduced = false else
if next_s.pow != 1 W.symbols[i+1].typ.perm.d = p
next_s = perm_autsymbol(perm(next_s), pow=next_s.pow) push!(to_delete, i)
end
p1 = getperm(current)
p2 = getperm(next_s)
W.symbols[i] = id_autsymbol()
W.symbols[i+1] = perm_autsymbol(p1*p2)
end end
end end
end end
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols)) deleteat!(W.symbols, to_delete)
return reduced return reduced
end end
function reduce!(W::Automorphism) function reduce!(W::Automorphism)
if length(W) < 2 if length(W.symbols) == 0
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols)) return W
elseif length(W.symbols) == 1 && W.symbols[1].pow == 0
deleteat!(W.symbols, 1)
W.modified = true
else else
reduced = false reduced = false
while !reduced while !reduced
reduced = simplify_perms!(W) && free_reduce!(W) reduced = simplify_perms!(W) && free_reduce!(W)
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols))
end end
end end
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols))
W.modified = true W.modified = true