mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2025-01-12 22:22:32 +01:00
add basic fallbacks
This commit is contained in:
parent
b92276ade2
commit
263444c2a9
@ -14,25 +14,9 @@ using LinearAlgebra
|
|||||||
using Markdown
|
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("types.jl")
|
||||||
include("gsymbols.jl")
|
include("gsymbols.jl")
|
||||||
|
include("fallbacks.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
|
|
||||||
|
|
||||||
@doc doc"""
|
@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