2021-06-21 18:16:04 +02:00
|
|
|
"""
|
|
|
|
wlmetric_ball(S::AbstractVector{<:GroupElem}
|
2023-03-22 21:41:37 +01:00
|
|
|
[, center=one(first(S)); radius=2, op=*])
|
2021-06-21 18:16:04 +02:00
|
|
|
Compute metric ball as a list of elements of non-decreasing length, given the
|
|
|
|
word-length metric on the group generated by `S`. The ball is centered at `center`
|
|
|
|
(by default: the identity element). `radius` and `op` keywords specify the
|
|
|
|
radius and multiplication operation to be used.
|
|
|
|
"""
|
2022-10-14 01:14:38 +02:00
|
|
|
function wlmetric_ball(
|
|
|
|
S::AbstractVector{T},
|
2023-03-15 19:07:14 +01:00
|
|
|
center::T = one(first(S));
|
|
|
|
radius = 2,
|
|
|
|
op = *,
|
2022-10-14 01:14:38 +02:00
|
|
|
) where {T}
|
2023-03-22 21:41:37 +01:00
|
|
|
ball = [center]
|
|
|
|
sizes = [1]
|
|
|
|
if radius ≤ 0
|
|
|
|
return ball, sizes[2:end]
|
|
|
|
else
|
|
|
|
ball = union!(ball, [center * s for s in S])
|
|
|
|
push!(sizes, length(ball))
|
|
|
|
if radius == 1
|
|
|
|
return ball, sizes[2:end]
|
|
|
|
else
|
|
|
|
for _ in 2:radius
|
|
|
|
new = collect(
|
|
|
|
op(o, s) for o in @view(ball[sizes[end-1]:end]) for s in S
|
|
|
|
)
|
2023-05-25 11:57:32 +02:00
|
|
|
ball = union!(ball, new)
|
2023-03-22 21:41:37 +01:00
|
|
|
push!(sizes, length(ball))
|
|
|
|
end
|
2021-06-21 18:16:04 +02:00
|
|
|
end
|
2023-03-22 21:41:37 +01:00
|
|
|
return ball, sizes[2:end]
|
2021-06-21 18:16:04 +02:00
|
|
|
end
|
2023-03-22 21:41:37 +01:00
|
|
|
# return wlmetric_ball_serial(S, center; radius = radius, op = op)
|
2021-06-21 18:16:04 +02:00
|
|
|
end
|