2017-11-08 09:06:50 +01:00
|
|
|
__precompile__()
|
2017-01-23 16:45:24 +01:00
|
|
|
module Groups
|
|
|
|
|
2017-05-11 17:34:07 +02:00
|
|
|
using Nemo
|
2017-06-22 15:04:51 +02:00
|
|
|
import Nemo: Group, GroupElem, Ring
|
|
|
|
import Nemo: parent, parent_type, elem_type
|
2017-07-05 16:26:14 +02:00
|
|
|
import Nemo: elements, order, gens
|
2017-05-11 17:34:07 +02:00
|
|
|
|
2017-01-25 12:18:01 +01:00
|
|
|
import Base: length, ==, hash, show, convert
|
2017-05-11 17:57:18 +02:00
|
|
|
import Base: inv, reduce, *, ^
|
2017-01-26 12:48:32 +01:00
|
|
|
import Base: findfirst, findnext
|
2017-05-11 17:34:07 +02:00
|
|
|
import Base: deepcopy_internal
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# ParentType / ObjectType definition
|
|
|
|
#
|
|
|
|
###############################################################################
|
2017-01-23 16:45:24 +01:00
|
|
|
|
2017-05-11 17:36:59 +02:00
|
|
|
doc"""
|
|
|
|
::GSymbol
|
2017-07-06 09:11:56 +02:00
|
|
|
> Abstract type which all group symbols of AbstractFPGroups should subtype. Each
|
2017-05-11 17:36:59 +02:00
|
|
|
> concrete subtype should implement fields:
|
|
|
|
> * `str` which is the string representation/identification of a symbol
|
|
|
|
> * `pow` which is the (multiplicative) exponent of a symbol.
|
|
|
|
|
|
|
|
"""
|
2017-09-13 11:22:21 +02:00
|
|
|
abstract type GSymbol end
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 17:59:37 +02:00
|
|
|
doc"""
|
|
|
|
W::GWord{T<:GSymbol} <:GroupElem
|
|
|
|
> Basic representation of element of a finitely presented group. `W.symbols`
|
|
|
|
> fieldname contains particular group symbols which multiplied constitute a
|
|
|
|
> group element, i.e. a word in generators.
|
|
|
|
> As reduction (inside group) of such word may be time consuming we provide
|
|
|
|
> `savedhash` and `modified` fields as well:
|
|
|
|
> hash (used e.g. in the `unique` function) is calculated by reducing the word,
|
|
|
|
> setting `modified` flag to `false` and computing the hash which is stored in
|
|
|
|
> `savedhash` field.
|
|
|
|
> whenever word `W` is changed `W.modified` is set to `false`;
|
|
|
|
> Future comparisons don't perform reduction (and use `savedhash`) as long as
|
|
|
|
> `modified` flag remains `false`.
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 17:59:37 +02:00
|
|
|
"""
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
abstract type GWord{T<:GSymbol} <:GroupElem end
|
|
|
|
|
|
|
|
mutable struct GroupWord{T} <: GWord{T}
|
2017-07-06 17:27:56 +02:00
|
|
|
symbols::Vector{T}
|
|
|
|
savedhash::UInt
|
|
|
|
modified::Bool
|
|
|
|
parent::Group
|
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
function GroupWord{T}(symbols::Vector{T}) where {T}
|
2017-09-13 16:47:31 +02:00
|
|
|
return new{T}(symbols, hash(symbols), true)
|
2017-07-06 17:27:56 +02:00
|
|
|
end
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
|
2017-09-13 11:22:21 +02:00
|
|
|
abstract type AbstractFPGroup <: Group end
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Type and parent object methods
|
|
|
|
#
|
|
|
|
###############################################################################
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:01:55 +02:00
|
|
|
parent{T<:GSymbol}(w::GWord{T}) = w.parent
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# ParentType / ObjectType constructors
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
GroupWord(s::T) where {T<:GSymbol} = GroupWord{T}(T[s])
|
|
|
|
convert(::Type{GroupWord{T}}, s::T) where {T<:GSymbol} = GroupWord{T}(T[s])
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Basic manipulation
|
|
|
|
#
|
|
|
|
###############################################################################
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:00:46 +02:00
|
|
|
function hash(W::GWord, h::UInt)
|
|
|
|
W.modified && reduce!(W)
|
2017-09-13 11:22:21 +02:00
|
|
|
res = xor(W.savedhash, h)
|
2017-07-06 09:22:56 +02:00
|
|
|
return res
|
2017-05-11 18:00:46 +02:00
|
|
|
end
|
2017-05-11 18:03:06 +02:00
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
function deepcopy_internal(W::T, dict::ObjectIdDict) where {T<:GWord}
|
2017-05-11 18:03:06 +02:00
|
|
|
G = parent(W)
|
2018-03-25 23:46:13 +02:00
|
|
|
return G(T(deepcopy(W.symbols)))
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
2017-05-11 18:03:06 +02:00
|
|
|
|
2017-09-13 16:47:31 +02:00
|
|
|
isone(s::GSymbol) = s.pow == 0
|
2017-05-12 19:46:59 +02:00
|
|
|
|
2017-05-11 17:49:56 +02:00
|
|
|
length(W::GWord) = sum([length(s) for s in W.symbols])
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 17:51:16 +02:00
|
|
|
function free_reduce!(W::GWord)
|
2017-01-23 16:53:33 +01:00
|
|
|
reduced = true
|
|
|
|
for i in 1:length(W.symbols) - 1
|
2017-05-11 18:09:09 +02:00
|
|
|
if W.symbols[i].str == W.symbols[i+1].str
|
2017-01-23 16:53:33 +01:00
|
|
|
reduced = false
|
|
|
|
p1 = W.symbols[i].pow
|
|
|
|
p2 = W.symbols[i+1].pow
|
|
|
|
W.symbols[i+1] = change_pow(W.symbols[i], p1 + p2)
|
2017-05-11 17:57:18 +02:00
|
|
|
W.symbols[i] = change_pow(W.symbols[i], 0)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
end
|
2017-05-11 17:52:14 +02:00
|
|
|
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols))
|
2017-01-23 16:53:33 +01:00
|
|
|
return reduced
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:03:46 +02:00
|
|
|
function reduce!(W::GWord)
|
2017-01-23 16:53:33 +01:00
|
|
|
if length(W) < 2
|
|
|
|
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols))
|
|
|
|
else
|
|
|
|
reduced = false
|
|
|
|
while !reduced
|
2017-05-11 17:51:16 +02:00
|
|
|
reduced = free_reduce!(W)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
W.modified = false
|
2017-05-11 18:03:46 +02:00
|
|
|
W.savedhash = hash(W.symbols, hash(typeof(W)))
|
2017-01-23 16:53:33 +01:00
|
|
|
return W
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:03:46 +02:00
|
|
|
doc"""
|
|
|
|
reduce(W::GWord)
|
|
|
|
> performs reduction/simplification of a group element (word in generators).
|
|
|
|
> The default reduction is the free group reduction, i.e. consists of
|
|
|
|
> multiplying adjacent symbols with the same `str` identifier and deleting the
|
|
|
|
> identity elements from `W.symbols`.
|
|
|
|
> More specific procedures should be dispatched on `GWord`s type parameter.
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:03:46 +02:00
|
|
|
"""
|
|
|
|
reduce(W::GWord) = reduce!(deepcopy(W))
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-07-06 09:05:24 +02:00
|
|
|
doc"""
|
|
|
|
gens(G::AbstractFPGroups)
|
|
|
|
> returns vector of generators of `G`, as its elements.
|
|
|
|
|
|
|
|
"""
|
2017-07-06 09:11:27 +02:00
|
|
|
gens(G::AbstractFPGroup) = [G(g) for g in G.gens]
|
2017-07-05 16:26:14 +02:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# String I/O
|
|
|
|
#
|
|
|
|
###############################################################################
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
doc"""
|
|
|
|
show(io::IO, W::GWord)
|
2017-05-19 10:35:29 +02:00
|
|
|
> The actual string produced by show depends on the eltype of `W.symbols`.
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
"""
|
2017-01-23 16:53:33 +01:00
|
|
|
function show(io::IO, W::GWord)
|
|
|
|
if length(W) == 0
|
|
|
|
print(io, "(id)")
|
|
|
|
else
|
|
|
|
join(io, [string(s) for s in W.symbols], "*")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-13 16:47:31 +02:00
|
|
|
function show(io::IO, s::T) where {T<:GSymbol}
|
2017-05-12 19:48:33 +02:00
|
|
|
if isone(s)
|
|
|
|
print(io, "(id)")
|
|
|
|
elseif s.pow == 1
|
|
|
|
print(io, s.str)
|
|
|
|
else
|
|
|
|
print(io, (s.str)*"^$(s.pow)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Comparison
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2017-05-11 18:05:03 +02:00
|
|
|
function (==)(W::GWord, Z::GWord)
|
|
|
|
parent(W) == parent(Z) || return false
|
|
|
|
W.modified && reduce!(W) # reduce clears the flag and calculates savedhash
|
|
|
|
Z.modified && reduce!(Z)
|
|
|
|
return W.savedhash == Z.savedhash && W.symbols == Z.symbols
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Binary operators
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2017-01-23 16:53:33 +01:00
|
|
|
function r_multiply!(W::GWord, x; reduced::Bool=true)
|
|
|
|
if length(x) > 0
|
2018-03-21 19:21:03 +01:00
|
|
|
append!(W.symbols, x)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
if reduced
|
2017-01-31 16:56:49 +01:00
|
|
|
reduce!(W)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
return W
|
|
|
|
end
|
|
|
|
|
2018-03-21 19:21:03 +01:00
|
|
|
function l_multiply!(W::GWord, x; reduced::Bool=true)
|
2017-01-23 16:53:33 +01:00
|
|
|
if length(x) > 0
|
2018-03-21 19:21:03 +01:00
|
|
|
prepend!(W.symbols, x)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
if reduced
|
2017-01-31 16:56:49 +01:00
|
|
|
reduce!(W)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
return W
|
|
|
|
end
|
|
|
|
|
2017-05-12 19:46:08 +02:00
|
|
|
r_multiply(W::GWord, x; reduced=true) =
|
2017-01-23 16:53:33 +01:00
|
|
|
r_multiply!(deepcopy(W),x, reduced=reduced)
|
2017-05-12 19:46:08 +02:00
|
|
|
l_multiply(W::GWord, x; reduced=true) =
|
2017-01-23 16:53:33 +01:00
|
|
|
l_multiply!(deepcopy(W),x, reduced=reduced)
|
|
|
|
|
2017-05-11 18:07:57 +02:00
|
|
|
(*)(W::GWord, Z::GWord) = r_multiply(W, Z.symbols)
|
|
|
|
(*)(W::GWord, s::GSymbol) = r_multiply(W, [s])
|
|
|
|
(*)(s::GSymbol, W::GWord) = l_multiply(W, [s])
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-05-11 18:07:57 +02:00
|
|
|
function power_by_squaring(W::GWord, p::Integer)
|
2017-01-23 16:53:33 +01:00
|
|
|
if p < 0
|
2017-05-11 18:07:57 +02:00
|
|
|
return power_by_squaring(inv(W), -p)
|
2017-01-23 16:53:33 +01:00
|
|
|
elseif p == 0
|
2017-05-11 17:57:18 +02:00
|
|
|
return parent(W)()
|
2017-01-23 16:53:33 +01:00
|
|
|
elseif p == 1
|
2017-05-11 18:07:57 +02:00
|
|
|
return W
|
2017-01-23 16:53:33 +01:00
|
|
|
elseif p == 2
|
2017-05-11 18:07:57 +02:00
|
|
|
return W*W
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
2017-05-11 18:07:57 +02:00
|
|
|
W = deepcopy(W)
|
2017-01-23 16:53:33 +01:00
|
|
|
t = trailing_zeros(p) + 1
|
|
|
|
p >>= t
|
|
|
|
while (t -= 1) > 0
|
2017-05-11 18:07:57 +02:00
|
|
|
r_multiply!(W, W.symbols)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
2017-05-11 18:07:57 +02:00
|
|
|
Z = deepcopy(W)
|
2017-01-23 16:53:33 +01:00
|
|
|
while p > 0
|
|
|
|
t = trailing_zeros(p) + 1
|
|
|
|
p >>= t
|
|
|
|
while (t -= 1) >= 0
|
2017-05-11 18:07:57 +02:00
|
|
|
r_multiply!(W, W.symbols)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
2017-05-11 18:07:57 +02:00
|
|
|
r_multiply!(Z, W.symbols)
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
2017-05-11 18:07:57 +02:00
|
|
|
return Z
|
2017-01-23 16:53:33 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
(^)(x::GWord, n::Integer) = power_by_squaring(x,n)
|
2017-05-11 17:58:19 +02:00
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Inversion
|
|
|
|
#
|
2017-05-11 17:58:19 +02:00
|
|
|
###############################################################################
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
function inv(W::T) where {T<:GWord}
|
2017-05-11 17:43:33 +02:00
|
|
|
if length(W) == 0
|
|
|
|
return W
|
|
|
|
else
|
|
|
|
G = parent(W)
|
2018-03-25 23:46:13 +02:00
|
|
|
w = T(reverse([inv(s) for s in W.symbols]))
|
2017-05-11 17:43:33 +02:00
|
|
|
w.modified = true
|
|
|
|
return G(w)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Replacement of symbols / sub-words
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2017-01-25 10:57:48 +01:00
|
|
|
is_subsymbol(s::GSymbol, t::GSymbol) =
|
2017-05-11 18:09:09 +02:00
|
|
|
s.str == t.str && (0 ≤ s.pow ≤ t.pow || 0 ≥ s.pow ≥ t.pow)
|
2017-01-25 10:57:48 +01:00
|
|
|
|
2017-01-26 12:48:32 +01:00
|
|
|
function findfirst(W::GWord, Z::GWord)
|
2017-01-25 11:30:46 +01:00
|
|
|
n = length(Z.symbols)
|
|
|
|
|
2017-07-05 16:16:47 +02:00
|
|
|
if n == 0
|
|
|
|
return 0
|
|
|
|
elseif n == 1
|
|
|
|
for (i,s) in enumerate(W.symbols)
|
|
|
|
if is_subsymbol(Z.symbols[1], s)
|
|
|
|
return i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
for (idx,a) in enumerate(W.symbols)
|
|
|
|
if idx + n - 1 > length(W.symbols)
|
2017-01-25 11:30:46 +01:00
|
|
|
break
|
2017-07-05 16:16:47 +02:00
|
|
|
end
|
|
|
|
foundfirst = is_subsymbol(Z.symbols[1], a)
|
|
|
|
if foundfirst
|
2017-05-18 12:21:31 +02:00
|
|
|
middlematch = W.symbols[idx+1:idx+n-2] == Z.symbols[2:end-1]
|
|
|
|
lastmatch = is_subsymbol(Z.symbols[end], W.symbols[idx+n-1])
|
|
|
|
if middlematch && lastmatch
|
2017-07-05 16:16:47 +02:00
|
|
|
return idx
|
2017-01-25 11:30:46 +01:00
|
|
|
end
|
2017-07-05 16:16:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return 0
|
2017-01-25 11:30:46 +01:00
|
|
|
end
|
|
|
|
|
2017-01-26 12:48:32 +01:00
|
|
|
function findnext(W::GWord, Z::GWord, i::Integer)
|
|
|
|
t = findfirst(GWord{eltype(W.symbols)}(W.symbols[i:end]), Z)
|
|
|
|
if t > 0
|
|
|
|
return t+i-1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2017-01-25 11:32:12 +01:00
|
|
|
|
2017-05-11 18:09:55 +02:00
|
|
|
function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; check=true)
|
2017-07-05 16:18:04 +02:00
|
|
|
n = length(toreplace.symbols)
|
|
|
|
if n == 0
|
|
|
|
return reduce!(W)
|
2017-01-25 11:32:12 +01:00
|
|
|
|
2017-07-05 16:18:04 +02:00
|
|
|
elseif n == 1
|
|
|
|
if check
|
|
|
|
@assert is_subsymbol(toreplace.symbols[1], W.symbols[index])
|
|
|
|
end
|
|
|
|
|
|
|
|
first = change_pow(W.symbols[index],
|
|
|
|
W.symbols[index].pow - toreplace.symbols[1].pow)
|
|
|
|
last = change_pow(W.symbols[index], 0)
|
2017-05-11 18:09:39 +02:00
|
|
|
|
2017-07-05 16:18:04 +02:00
|
|
|
else
|
|
|
|
if check
|
|
|
|
@assert is_subsymbol(toreplace.symbols[1], W.symbols[index])
|
|
|
|
@assert W.symbols[index+1:index+n-2] == toreplace.symbols[2:end-1]
|
|
|
|
@assert is_subsymbol(toreplace.symbols[end], W.symbols[index+n-1])
|
|
|
|
end
|
|
|
|
|
|
|
|
first = change_pow(W.symbols[index],
|
|
|
|
W.symbols[index].pow - toreplace.symbols[1].pow)
|
|
|
|
last = change_pow(W.symbols[index+n-1],
|
2017-05-11 18:09:39 +02:00
|
|
|
W.symbols[index+n-1].pow - toreplace.symbols[end].pow)
|
2017-07-05 16:18:04 +02:00
|
|
|
end
|
2017-05-11 18:09:39 +02:00
|
|
|
|
2017-07-05 16:18:04 +02:00
|
|
|
replacement = first * replacement * last
|
|
|
|
splice!(W.symbols, index:index+n-1, replacement.symbols)
|
|
|
|
return reduce!(W)
|
2017-01-25 11:32:12 +01:00
|
|
|
end
|
|
|
|
|
2017-01-26 12:50:54 +01:00
|
|
|
function replace(W::GWord, index, toreplace::GWord, replacement::GWord)
|
|
|
|
replace!(deepcopy(W), index, toreplace, replacement)
|
|
|
|
end
|
|
|
|
|
2017-09-13 16:47:31 +02:00
|
|
|
function replace_all!(W::GWord{T},subst_dict::Dict{GWord{T},GWord{T}}) where {T}
|
2017-07-06 09:18:53 +02:00
|
|
|
modified = false
|
2017-07-05 16:22:50 +02:00
|
|
|
for toreplace in reverse!(sort!(collect(keys(subst_dict)), by=length))
|
2017-01-25 11:32:12 +01:00
|
|
|
replacement = subst_dict[toreplace]
|
|
|
|
i = findfirst(W, toreplace)
|
|
|
|
while i ≠ 0
|
2017-07-06 09:18:53 +02:00
|
|
|
modified = true
|
2017-01-25 11:32:12 +01:00
|
|
|
replace!(W,i,toreplace, replacement)
|
2017-01-26 12:51:48 +01:00
|
|
|
i = findnext(W, toreplace, i)
|
2017-01-25 11:32:12 +01:00
|
|
|
end
|
|
|
|
end
|
2017-07-06 09:18:53 +02:00
|
|
|
return modified
|
2017-01-25 11:32:12 +01:00
|
|
|
end
|
|
|
|
|
2017-09-13 16:47:31 +02:00
|
|
|
function replace_all(W::GWord{T},subst_dict::Dict{GWord{T},GWord{T}}) where {T}
|
2017-07-06 09:19:15 +02:00
|
|
|
W = deepcopy(W)
|
|
|
|
replace_all!(W, subst_dict)
|
|
|
|
return W
|
|
|
|
end
|
2017-01-26 12:50:54 +01:00
|
|
|
|
2017-05-17 17:46:30 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Misc
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2018-03-25 23:46:13 +02:00
|
|
|
function generate_balls(S::Vector{T}, Id::T=parent(first(S))(); radius=2, op=*) where T<:GWord
|
2017-11-05 14:58:58 +01:00
|
|
|
sizes = Int[]
|
2017-05-17 17:46:30 +02:00
|
|
|
B = [Id]
|
|
|
|
for i in 1:radius
|
2017-11-05 14:58:58 +01:00
|
|
|
BB = [op(i,j) for (i,j) in Base.product(B,S)]
|
|
|
|
B = unique([B; vec(BB)])
|
2017-05-17 17:46:30 +02:00
|
|
|
push!(sizes, length(B))
|
|
|
|
end
|
|
|
|
return B, sizes
|
|
|
|
end
|
|
|
|
|
2017-11-08 11:09:29 +01:00
|
|
|
function generate_balls{T<:RingElem}(S::Vector{T}, Id::T=one(parent(first(S))); radius=2, op=*)
|
|
|
|
sizes = Int[]
|
2017-05-17 17:46:30 +02:00
|
|
|
B = [Id]
|
|
|
|
for i in 1:radius
|
2017-11-08 11:09:29 +01:00
|
|
|
BB = [op(i,j) for (i,j) in Base.product(B,S)]
|
|
|
|
B = unique([B; vec(BB)])
|
2017-05-17 17:46:30 +02:00
|
|
|
push!(sizes, length(B))
|
|
|
|
end
|
|
|
|
return B, sizes
|
|
|
|
end
|
|
|
|
|
2017-05-11 18:10:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Includes
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2017-05-12 20:15:03 +02:00
|
|
|
include("FreeGroup.jl")
|
2017-07-06 09:12:35 +02:00
|
|
|
include("FPGroups.jl")
|
2017-05-12 20:15:03 +02:00
|
|
|
include("AutGroup.jl")
|
2017-01-23 16:53:33 +01:00
|
|
|
|
2017-06-22 15:04:51 +02:00
|
|
|
include("DirectProducts.jl")
|
|
|
|
include("WreathProducts.jl")
|
|
|
|
|
2017-01-23 16:53:33 +01:00
|
|
|
end # of module Groups
|