1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-09-13 00:20:40 +02: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)
@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
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)
G = rs[]
symmgens_len = length(alphabet(F))
return FPGroupElement(word_type(G)(rand(1:symmgens_len, l)), G)
nletters = length(alphabet(G))
return FPGroupElement(word_type(G)(rand(1:nletters, l)), G)
end
## FPGroupElement
@ -204,10 +205,10 @@ struct FreeGroup{T} <: AbstractFPGroup
end
end
function FreeGroup(a::Alphabet)
function FreeGroup(A::Alphabet)
@boundscheck @assert all(KnuthBendix.hasinverse(l, A)
for l in KnuthBendix.letters(a))
return FreeGroup(KnuthBendix.letters(a), a)
for l in KnuthBendix.letters(A))
return FreeGroup(KnuthBendix.letters(A), A)
end
Base.show(io::IO, F::FreeGroup) = print(io, "free group on $(ngens(F)) generators")