mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
add Misc category with: products, generate_balls
This commit is contained in:
parent
40fb5566d7
commit
c03882ae69
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user