1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-24 18:05:27 +01:00

add Misc category with: products, generate_balls

This commit is contained in:
kalmar 2017-05-17 17:46:30 +02:00
parent 40fb5566d7
commit c03882ae69

View File

@ -330,6 +330,39 @@ end
replace_all(W::GWord, subst_dict::Dict{GWord, GWord}) = replace_all!(deepcopy(W), subst_dict)
###############################################################################
#
# Misc
#
###############################################################################
function products{T}(X::AbstractVector{T}, Y::AbstractVector{T})
result = Vector{T}()
seen = Set{T}()
for x in X
for y in Y
z = x*y
if !in(z, seen)
push!(seen, z)
push!(result, z)
end
end
end
return result
end
function generate_balls(S, Id; radius=2)
sizes = Vector{Int}()
S = unshift!(S, Id)
B = [Id]
for i in 1:radius
B = products(B, S);
push!(sizes, length(B))
end
return B, sizes
end
###############################################################################
#
# Includes