mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
unify the two definitions of generate_balls; rename to metric_ball
This commit is contained in:
parent
12be3b75bc
commit
b125871697
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user