create and use uniform API for GSymbols

This commit is contained in:
kalmarek 2020-03-24 23:47:50 +01:00
parent 5810eeb4ae
commit 7b211014e3
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
4 changed files with 12 additions and 17 deletions

View File

@ -304,8 +304,6 @@ function change_pow(s::AutSymbol, n::Integer)
end
end
length(s::AutSymbol) = abs(s.pow)
###############################################################################
#
# String I/O
@ -329,8 +327,6 @@ end
#
###############################################################################
inv(f::AutSymbol) = change_pow(f, -f.pow)
###############################################################################
#
# Misc

View File

@ -95,10 +95,6 @@ end
#
###############################################################################
change_pow(s::FPSymbol, n::Int) = FPSymbol(s.id, n)
length(s::FPSymbol) = abs(s.pow)
###############################################################################
#
# String I/O
@ -127,8 +123,6 @@ end
#
###############################################################################
inv(s::FPSymbol) = change_pow(s, -s.pow)
###############################################################################
#
# Binary operations

View File

@ -80,10 +80,6 @@ end
#
###############################################################################
change_pow(s::FreeSymbol, n::Int) = FreeSymbol(s.id, n)
length(s::FreeSymbol) = abs(s.pow)
###############################################################################
#
# String I/O
@ -106,5 +102,3 @@ end
# Inversion
#
###############################################################################
inv(s::FreeSymbol) = change_pow(s, -s.pow)

View File

@ -33,7 +33,18 @@ Base.one(G::Generic.PermGroup) = G(collect(1:G.n), false)
"""
abstract type GSymbol end
abstract type GWord{T<:GSymbol} <:GroupElem end
Base.iterate(s::GS, i=1) where GS<:GSymbol = i <= abs(s.pow) ? (GS(s.id, sign(s.pow)), i+1) : nothing
Base.length(s::GSymbol) = abs(s.pow)
Base.size(s::GSymbol) = (length(s), )
Base.eltype(s::GS) where GS<:GSymbol = GS
Base.isone(s::GSymbol) = iszero(s.pow)
change_pow(s::S, n::Integer) where S<:GSymbol = S(s.id, n)
Base.inv(s::GSymbol) = change_pow(s, -s.pow)
hash(s::S, h::UInt) where S<:GSymbol = hash(s.id, hash(s.pow, hash(S, h)))
abstract type GWord{T<:GSymbol} <: GroupElem end
@doc doc"""
W::GroupWord{T} <: GWord{T<:GSymbol} <:GroupElem