mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
add New.FreeGroup(n::Integer) method
This commit is contained in:
parent
c0c688ed2d
commit
3a88728e0a
@ -134,6 +134,18 @@ function FreeGroup(A::Alphabet)
|
||||
return FreeGroup(KnuthBendix.letters(A), A)
|
||||
end
|
||||
|
||||
function FreeGroup(n::Integer)
|
||||
symbols = Symbol[]
|
||||
inverses = Int[]
|
||||
sizehint!(symbols, 2n)
|
||||
sizehint!(inverses, 2n)
|
||||
for i in 1:n
|
||||
push!(symbols, Symbol(:f, i), Symbol(:F, i))
|
||||
push!(inverses, 2i, 2i-1)
|
||||
end
|
||||
return FreeGroup(symbols[1:2:2n], Alphabet(symbols, inverses))
|
||||
end
|
||||
|
||||
Base.show(io::IO, F::FreeGroup) = print(io, "free group on $(ngens(F)) generators")
|
||||
|
||||
# mandatory methods:
|
||||
|
Loading…
Reference in New Issue
Block a user