1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

much faster generate_balls (using Base.product)

This commit is contained in:
kalmarek 2017-11-08 11:09:29 +01:00
parent 99c07c6909
commit 70cde44673

View File

@ -390,6 +390,17 @@ function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T=parent(first(S))(); ra
return B, sizes
end
function generate_balls{T<:RingElem}(S::Vector{T}, Id::T=one(parent(first(S))); radius=2, op=*)
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
###############################################################################
#
# Includes