mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
fix FPGroups and add basic tests
This commit is contained in:
parent
dd4ed1497c
commit
4bcd851031
@ -42,6 +42,7 @@ elem_type(::FPGroup) = FPGroupElem
|
||||
|
||||
FPSymbol(s::Symbol) = FPSymbol(s, 1)
|
||||
FPSymbol(s::String) = FPSymbol(Symbol(s))
|
||||
FPSymbol(s::GSymbol) = FPSymbol(s.id, s.pow)
|
||||
|
||||
convert(::Type{FPSymbol}, s::FreeSymbol) = FPSymbol(s.id, s.pow)
|
||||
|
||||
@ -70,7 +71,7 @@ function (G::FPGroup)(w::GWord)
|
||||
end
|
||||
|
||||
if eltype(w.symbols) == FreeSymbol
|
||||
w = FPGroupElem(w.symbols)
|
||||
w = FPGroupElem(FPSymbol.(w.symbols))
|
||||
end
|
||||
|
||||
if eltype(w.symbols) == FPSymbol
|
||||
@ -169,8 +170,8 @@ function add_rels!(G::FPGroup, newrels::Dict{FPGroupElem,FPGroupElem})
|
||||
end
|
||||
end
|
||||
|
||||
function /(G::FPGroup, newrels::Vector{FPGroupElem})
|
||||
for r in rels
|
||||
function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem})
|
||||
for r in newrels
|
||||
parent(r) == G || throw(DomainError(
|
||||
"Can not form quotient group: $r is not an element of $G"))
|
||||
end
|
||||
@ -180,12 +181,12 @@ function /(G::FPGroup, newrels::Vector{FPGroupElem})
|
||||
return H
|
||||
end
|
||||
|
||||
function /(G::FreeGroup, rels::Vector{FreeGroupElem})
|
||||
function Base.:/(G::FreeGroup, rels::Vector{FreeGroupElem})
|
||||
for r in rels
|
||||
parent(r) == G || throw(DomainError(
|
||||
"Can not form quotient group: $r is not an element of $G"))
|
||||
end
|
||||
H = FPGroup(G)
|
||||
H = FPGroup(deepcopy(G))
|
||||
H.rels = Dict(H(rel) => one(H) for rel in unique(rels))
|
||||
return H
|
||||
end
|
||||
|
15
test/FPGroup-tests.jl
Normal file
15
test/FPGroup-tests.jl
Normal file
@ -0,0 +1,15 @@
|
||||
@testset "FPGroups definitions" begin
|
||||
F = FreeGroup(["a", "b", "c"])
|
||||
a,b,c = gens(F)
|
||||
R = [a^2, a*b*a, c*b*a]
|
||||
@test F/R isa FPGroup
|
||||
@test F isa FreeGroup
|
||||
G = F/R
|
||||
A,B,C = gens(G)
|
||||
|
||||
@test A^2 == one(G)
|
||||
@test A*B*A*A == A
|
||||
@test A*A*B*A == B*A
|
||||
|
||||
@test G/[B^2, C*B*C] isa FPGroup
|
||||
end
|
@ -21,4 +21,5 @@ using LinearAlgebra
|
||||
include("AutGroup-tests.jl")
|
||||
include("DirectPower-tests.jl")
|
||||
include("WreathProd-tests.jl")
|
||||
include("FPGroup-tests.jl")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user