add basic fallbacks

This commit is contained in:
kalmarek 2020-03-25 04:16:21 +01:00
parent b92276ade2
commit 263444c2a9
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 18 additions and 17 deletions

View File

@ -14,25 +14,9 @@ using LinearAlgebra
using Markdown
Base.one(G::Generic.PermGroup) = Generic.Perm(G.n)
Base.one(r::NCRingElem) = one(parent(r))
###############################################################################
#
# ParentType / ObjectType definition
#
include("types.jl")
include("gsymbols.jl")
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
include("fallbacks.jl")
@doc doc"""

17
src/fallbacks.jl Normal file
View File

@ -0,0 +1,17 @@
# workarounds
Base.one(G::Generic.PermGroup) = Generic.Perm(G.n)
Base.one(r::NCRingElem) = one(parent(r))
# fallback definitions
# note: the user should implement those on type, when possible
Base.eltype(w::GW) where GW<:GWord = eltype(GW)
AbstractAlgebra.elem_type(G::Gr) where Gr <:AbstractFPGroup = elem_type(Gr)
AbstractAlgebra.parent_type(g::Gw) where Gw <:GWord = parent_type(parent(Gr))
function Base.one(G::Gr) where Gr <: AbstractFPGroup
El = elem_type(G)
id = El(eltype(El)[])
id.parent = G
return id
end