mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2025-01-07 21:15:28 +01:00
add test for hash/normalform
This commit is contained in:
parent
93a841359b
commit
126c8bbc22
15
src/types.jl
15
src/types.jl
@ -88,6 +88,9 @@ end
|
|||||||
|
|
||||||
abstract type AbstractFPGroupElement{Gr} <: GroupElement end
|
abstract type AbstractFPGroupElement{Gr} <: GroupElement end
|
||||||
|
|
||||||
|
Base.copy(g::AbstractFPGroupElement) = one(g) * g
|
||||||
|
word(f::AbstractFPGroupElement) = f.word
|
||||||
|
|
||||||
mutable struct FPGroupElement{Gr<:AbstractFPGroup,W<:AbstractWord} <:
|
mutable struct FPGroupElement{Gr<:AbstractFPGroup,W<:AbstractWord} <:
|
||||||
AbstractFPGroupElement{Gr}
|
AbstractFPGroupElement{Gr}
|
||||||
word::W
|
word::W
|
||||||
@ -111,7 +114,9 @@ function Base.show(io::IO, ::Type{<:FPGroupElement{Gr}}) where {Gr}
|
|||||||
return print(io, FPGroupElement, "{$Gr, …}")
|
return print(io, FPGroupElement, "{$Gr, …}")
|
||||||
end
|
end
|
||||||
|
|
||||||
word(f::AbstractFPGroupElement) = f.word
|
function Base.copy(f::FPGroupElement)
|
||||||
|
return FPGroupElement(copy(word(f)), parent(f), f.savedhash)
|
||||||
|
end
|
||||||
|
|
||||||
#convenience
|
#convenience
|
||||||
KnuthBendix.alphabet(g::AbstractFPGroupElement) = alphabet(parent(g))
|
KnuthBendix.alphabet(g::AbstractFPGroupElement) = alphabet(parent(g))
|
||||||
@ -134,7 +139,13 @@ function Base.:(==)(g::AbstractFPGroupElement, h::AbstractFPGroupElement)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Base.deepcopy_internal(g::FPGroupElement, stackdict::IdDict)
|
function Base.deepcopy_internal(g::FPGroupElement, stackdict::IdDict)
|
||||||
return FPGroupElement(copy(word(g)), parent(g), g.savedhash)
|
haskey(stackdict, objectid(g)) && return stackdict[objectid(g)]
|
||||||
|
cw = if haskey(stackdict, objectid(word(g)))
|
||||||
|
stackdict[objectid(word(g))]
|
||||||
|
else
|
||||||
|
copy(word(g))
|
||||||
|
end
|
||||||
|
return FPGroupElement(cw, parent(g), g.savedhash)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.inv(g::GEl) where {GEl<:AbstractFPGroupElement}
|
function Base.inv(g::GEl) where {GEl<:AbstractFPGroupElement}
|
||||||
|
@ -64,4 +64,24 @@
|
|||||||
test_GroupElement_interface(rand(H, 2)...)
|
test_GroupElement_interface(rand(H, 2)...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "hash/normalform #28" begin
|
||||||
|
function cyclic_group(n::Integer)
|
||||||
|
A = Alphabet([:a, :A], [2, 1])
|
||||||
|
F = FreeGroup(A)
|
||||||
|
a, = Groups.gens(F)
|
||||||
|
e = one(F)
|
||||||
|
Cₙ = FPGroup(F, [a^n => e])
|
||||||
|
|
||||||
|
return Cₙ
|
||||||
|
end
|
||||||
|
|
||||||
|
n = 15
|
||||||
|
G = cyclic_group(n)
|
||||||
|
ball, sizes = Groups.wlmetric_ball(gens(G); radius = n)
|
||||||
|
@test first(sizes) == 2
|
||||||
|
@test last(sizes) == n
|
||||||
|
|
||||||
|
@test Set(ball) == Set([first(gens(G))^i for i in 0:n-1])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user