1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-26 02:20:30 +01:00

unify the two definitions of generate_balls; rename to metric_ball

This commit is contained in:
kalmarek 2020-03-25 05:23:06 +01:00
parent 12be3b75bc
commit b125871697
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -75,45 +75,31 @@ end
# #
# Misc # Misc
# #
###############################################################################
function generate_balls(S::AbstractVector{T}, Id::T=one(parent(first(S))); @doc doc"""
radius=2, op=*) where T<:GroupElem gens(G::AbstractFPGroups)
> returns vector of generators of `G`, as its elements.
"""
AbstractAlgebra.gens(G::AbstractFPGroup) = G.(G.gens)
@doc doc"""
metric_ball(S::Vector{GroupElem}, center=Id; radius=2, op=*)
Compute metric ball as a list of elements of non-decreasing length, given the
word-length metric on group generated by `S`. The ball is centered at `center`
(by default: the identity element). `radius` and `op` keywords specify the
radius and multiplication operation to be used.
"""
function generate_balls(S::AbstractVector{T}, center::T=one(first(S));
radius=2, op=*) where T<:Union{GroupElem, NCRingElem}
sizes = Int[] sizes = Int[]
B = [Id] B = [one(first(S))]
for i in 1:radius for i in 1:radius
BB = [op(i,j) for (i,j) in Base.product(B,S)] BB = [op(i,j) for (i,j) in Base.product(B,S)]
B = unique([B; vec(BB)]) B = unique([B; vec(BB)])
push!(sizes, length(B)) push!(sizes, length(B))
end end
return B, sizes isone(center) && return B, sizes
return c.*B, sizes
end end
function generate_balls(S::AbstractVector{T}, Id::T=one(parent(first(S)));
radius=2, op=*) where {T<:NCRingElem}
sizes = Int[]
B = [Id]
for i in 1:radius
BB = [op(i,j) for (i,j) in Base.product(B,S)]
B = unique([B; vec(BB)])
push!(sizes, length(B))
end
return B, sizes
end
########### iteration for GFField
length(F::AbstractAlgebra.GFField) = order(F)
function iterate(F::AbstractAlgebra.GFField, s=0)
if s >= order(F)
return nothing
else
return F(s), s+1
end
end
eltype(::Type{AbstractAlgebra.GFField{I}}) where I = AbstractAlgebra.gfelem{I}
end # of module Groups end # of module Groups