diff --git a/src/automorphism_groups.jl b/src/automorphism_groups.jl index e214c44..b7d9644 100644 --- a/src/automorphism_groups.jl +++ b/src/automorphism_groups.jl @@ -1,5 +1,6 @@ using Permutations +import Base: convert export AutSymbol, AutWord, rmul_AutSymbol, lmul_AutSymbol, flip_AutSymbol, symmetric_AutSymbol immutable AutSymbol <: GSymbol @@ -36,8 +37,7 @@ function change_pow(s::AutSymbol, n::Int) end end -inv(f::AutSymbol) = change_pow(f, -1*f.pow) -(^)(s::AutSymbol, n::Integer) = change_pow(s, s.pow*n) +inv(f::AutSymbol) = change_pow(f, -f.pow) function rmul_AutSymbol(i,j; pow::Int=1) gen = string('ϱ',Char(8320+i), Char(8320+j)...) @@ -76,6 +76,8 @@ end typealias AutWord GWord{AutSymbol} +convert(::Type{AutWord}, s::AutSymbol) = GWord(s) + function simplify_perms!(W::AutWord) reduced = true for i in 1:length(W.symbols) - 1 diff --git a/src/free_groups.jl b/src/free_groups.jl index 8e34932..bc149f5 100644 --- a/src/free_groups.jl +++ b/src/free_groups.jl @@ -13,9 +13,9 @@ hash(s::FGSymbol, h::UInt) = hash(s.gen, hash(s.pow, hash(:FGSymbol, h))) IdSymbol(::Type{FGSymbol}) = FGSymbol("(id)", 0) FGSymbol(x::String) = FGSymbol(x,1) -inv(s::FGSymbol) = FGSymbol(s.gen, -s.pow) convert(::Type{FGSymbol}, x::String) = FGSymbol(x) change_pow(s::FGSymbol, n::Int) = (n==0 ? i=one(s) : FGSymbol(s.gen, n)) +inv(s::FGSymbol) = change_pow(s, -s.pow) typealias FGWord GWord{FGSymbol}