mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 02:05:30 +01:00
add basic fallbacks
This commit is contained in:
parent
b92276ade2
commit
263444c2a9
@ -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
17
src/fallbacks.jl
Normal 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
|
Loading…
Reference in New Issue
Block a user