1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00
This commit is contained in:
Marek Kaluba 2021-05-05 02:33:36 +02:00
parent 288f06c070
commit be1602d11f
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -91,7 +91,8 @@ GroupsCore.ngens(G::AbstractFPGroup) = length(G.gens)
function GroupsCore.gens(G::AbstractFPGroup, i::Integer) function GroupsCore.gens(G::AbstractFPGroup, i::Integer)
@boundscheck 1<=i<=GroupsCore.ngens(G) @boundscheck 1<=i<=GroupsCore.ngens(G)
return FPGroupElement(word_type(G)([i]), G) l = alphabet(G)[G.gens[i]]
return FPGroupElement(word_type(G)([l]), G)
end end
GroupsCore.gens(G::AbstractFPGroup) = [gens(G, i) for i in 1:GroupsCore.ngens(G)] GroupsCore.gens(G::AbstractFPGroup) = [gens(G, i) for i in 1:GroupsCore.ngens(G)]
@ -102,8 +103,8 @@ function Base.rand(
) )
l = rand(10:100) l = rand(10:100)
G = rs[] G = rs[]
symmgens_len = length(alphabet(F)) nletters = length(alphabet(G))
return FPGroupElement(word_type(G)(rand(1:symmgens_len, l)), G) return FPGroupElement(word_type(G)(rand(1:nletters, l)), G)
end end
## FPGroupElement ## FPGroupElement
@ -204,10 +205,10 @@ struct FreeGroup{T} <: AbstractFPGroup
end end
end end
function FreeGroup(a::Alphabet) function FreeGroup(A::Alphabet)
@boundscheck @assert all(KnuthBendix.hasinverse(l, A) @boundscheck @assert all(KnuthBendix.hasinverse(l, A)
for l in KnuthBendix.letters(a)) for l in KnuthBendix.letters(A))
return FreeGroup(KnuthBendix.letters(a), a) return FreeGroup(KnuthBendix.letters(A), A)
end end
Base.show(io::IO, F::FreeGroup) = print(io, "free group on $(ngens(F)) generators") Base.show(io::IO, F::FreeGroup) = print(io, "free group on $(ngens(F)) generators")