(^) returns GWord _always_; inv(GSymbol) returns a symbol

This commit is contained in:
kalmar 2017-01-24 11:02:42 +01:00
parent c9d801eae8
commit 3099ab1987
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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}