mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
create and use uniform API for GSymbols
This commit is contained in:
parent
5810eeb4ae
commit
7b211014e3
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -33,6 +33,17 @@ Base.one(G::Generic.PermGroup) = G(collect(1:G.n), false)
|
||||
"""
|
||||
abstract type GSymbol 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"""
|
||||
|
Loading…
Reference in New Issue
Block a user