1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

move (==), hash, change_pow, inv

This commit is contained in:
kalmar 2017-05-12 20:04:03 +02:00
parent 26eb8b35cb
commit b130417a38

View File

@ -16,33 +16,9 @@ type AutGroup <: Group
objectGroup::Group
generators::Vector{AutSymbol}
end
(==)(s::AutSymbol, t::AutSymbol) = s.gen == t.gen && s.pow == t.pow
hash(s::AutSymbol, h::UInt) = hash(s.gen, hash(s.pow, hash(:AutSymbol, h)))
function change_pow(s::AutSymbol, n::Int)
if n == 0
return one(s)
end
symbol = s.ex.args[1]
if symbol ==
return flip_AutSymbol(s.ex.args[2], pow=n)
elseif symbol == :σ
return symmetric_AutSymbol(s.ex.args[2], pow=n)
elseif symbol == :ϱ
s.ex.args[2:end-1]
return rmul_AutSymbol(s.ex.args[2:end-1]..., pow=n)
elseif symbol ==
return lmul_AutSymbol(s.ex.args[2:end-1]..., pow=n)
elseif symbol == :id
return s
else
warn("Changing an unknown type of symbol! $s")
return AutSymbol(s.gen, n, s.ex, s.func)
end
end
inv(f::AutSymbol) = change_pow(f, -f.pow)
function id()
return v -> v
@ -147,6 +123,36 @@ function (F::AutGroupElem)(v)
end
hash(s::AutSymbol, h::UInt) = hash(s.gen, hash(s.pow, hash(:AutSymbol, h)))
function change_pow(s::AutSymbol, n::Int)
if n == 0
return one(s)
end
symbol = s.ex.args[1]
if symbol ==
return flip_autsymbol(s.ex.args[2], pow=n)
elseif symbol == :σ
return perm_autsymbol(s.ex.args[2], pow=n)
elseif symbol == :ϱ
s.ex.args[2:end-1]
return rmul_autsymbol(s.ex.args[2:end-1]..., pow=n)
elseif symbol ==
return lmul_autsymbol(s.ex.args[2:end-1]..., pow=n)
elseif symbol == :id
return s
else
warn("Changing an unknown type of symbol! $s")
return AutSymbol(s.gen, n, s.ex, s.func)
end
end
(==)(s::AutSymbol, t::AutSymbol) = s.gen == t.gen && s.pow == t.pow
inv(f::AutSymbol) = change_pow(f, -f.pow)
function simplify_perms!(W::AutGroupElem)
reduced = true
for i in 1:length(W.symbols) - 1