1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 18:15:29 +01:00

make one fully abstract method

This commit is contained in:
kalmarek 2020-03-25 03:33:43 +01:00
parent 99d5bc2f8c
commit a3db467bd1
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
4 changed files with 19 additions and 24 deletions

View File

@ -54,7 +54,7 @@ export Automorphism, AutGroup, Aut, SAut
#
###############################################################################
elem_type(::AutGroup{N}) where N = Automorphism{N}
elem_type(::Type{AutGroup{N}}) where N = Automorphism{N}
parent_type(::Automorphism{N}) where N = AutGroup{N}
@ -188,12 +188,6 @@ SAut(G::Group) = AutGroup(G, special=true)
Automorphism{N}(s::AutSymbol) where N = Automorphism{N}(AutSymbol[s])
function Base.one(G::AutGroup{N}) where N
id = Automorphism{N}(id_autsymbol())
id.parent = G
return id
end
function (G::AutGroup{N})(f::AutSymbol) where N
g = Automorphism{N}([f])
g.parent = G

View File

@ -30,10 +30,9 @@ export FPGroupElem, FPGroup
#
###############################################################################
elem_type(::Type{FPGroup}) = FPGroupElem
parent_type(::Type{FPGroupElem}) = FPGroup
elem_type(::FPGroup) = FPGroupElem
###############################################################################
#
# FPSymbol constructors
@ -59,12 +58,6 @@ FPGroup(H::FreeGroup) = FPGroup([FPSymbol(s) for s in H.gens])
#
###############################################################################
function Base.one(G::FPGroup)
id = FPGroupElem(FPSymbol[])
id.parent = G
return id
end
function (G::FPGroup)(w::GWord)
if isempty(w)
return one(G)

View File

@ -52,12 +52,6 @@ FreeGroup(a::Vector) = FreeGroup(FreeSymbol.(a))
#
###############################################################################
function Base.one(G::FreeGroup)
id = FreeGroupElem(FreeSymbol[])
id.parent = G
return id
end
function (G::FreeGroup)(w::GroupWord{FreeSymbol})
if length(syllables(w)) > 0
for s in w.symbols

View File

@ -15,13 +15,25 @@ export elements
using LinearAlgebra
using Markdown
Base.one(G::Generic.PermGroup) = G(collect(1:G.n), false)
Base.one(G::Generic.PermGroup) = Generic.Perm(G.n)
Base.one(r::NCRingElem) = one(parent(r))
###############################################################################
#
# ParentType / ObjectType definition
#
###############################################################################
abstract type AbstractFPGroup <: Group end
function Base.one(G::Gr) where Gr <: AbstractFPGroup
El = elem_type(G)
id = El(eltype(El)[])
id.parent = G
return id
end
elem_type(G::Gr) where Gr <:AbstractFPGroup = elem_type(Gr) # fallback definition
@doc doc"""
::GSymbol
@ -46,6 +58,8 @@ hash(s::S, h::UInt) where S<:GSymbol = hash(s.id, hash(s.pow, hash(S, h)))
abstract type GWord{T<:GSymbol} <: GroupElem end
# fallback definitions
Base.eltype(w::GW) where GW<:GWord = eltype(GW)
@doc doc"""
W::GroupWord{T} <: GWord{T<:GSymbol} <:GroupElem
> Basic representation of element of a finitely presented group. `W.symbols`
@ -77,8 +91,8 @@ syllables(w::GWord) = w.symbols
ismodified(w::GWord) = w.modified
setmodified!(w::GWord) = (w.modified = true; w)
unsetmodified!(w::GWord) = (w.modified = false; w)
Base.one(w::GWord) = one(parent(w))
abstract type AbstractFPGroup <: Group end
###############################################################################
#