mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 18:15:29 +01:00
allow for different group operation in generate_balls/products
This commit is contained in:
parent
4b68fe745f
commit
ff7bbe8e21
@ -371,12 +371,12 @@ replace_all{T<:GSymbol}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}}) = rep
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T})
|
function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T}, op=*)
|
||||||
result = Vector{T}()
|
result = Vector{T}()
|
||||||
seen = Set{T}()
|
seen = Set{T}()
|
||||||
for x in X
|
for x in X
|
||||||
for y in Y
|
for y in Y
|
||||||
z = x*y
|
z = op(x,y)
|
||||||
if !in(z, seen)
|
if !in(z, seen)
|
||||||
push!(seen, z)
|
push!(seen, z)
|
||||||
push!(result, z)
|
push!(result, z)
|
||||||
@ -386,12 +386,12 @@ function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T})
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T; radius=2)
|
function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T; radius=2, op=*)
|
||||||
sizes = Vector{Int}()
|
sizes = Vector{Int}()
|
||||||
S = unshift!(S, Id)
|
S = unshift!(S, Id)
|
||||||
B = [Id]
|
B = [Id]
|
||||||
for i in 1:radius
|
for i in 1:radius
|
||||||
B = products(B, S);
|
B = products(B, S, op);
|
||||||
push!(sizes, length(B))
|
push!(sizes, length(B))
|
||||||
end
|
end
|
||||||
return B, sizes
|
return B, sizes
|
||||||
|
Loading…
Reference in New Issue
Block a user