mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
format and bump to 0.5.0
This commit is contained in:
parent
837312d020
commit
2d66b4f56e
@ -1,7 +1,7 @@
|
||||
name = "Groups"
|
||||
uuid = "5d8bd718-bd84-11e8-3b40-ad14f4a32557"
|
||||
authors = ["Marek Kaluba <kalmar@amu.edu.pl>"]
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
|
||||
[deps]
|
||||
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
|
||||
@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
|
||||
|
||||
[compat]
|
||||
AbstractAlgebra = "^0.9.0"
|
||||
AbstractAlgebra = "^0.10.0"
|
||||
|
||||
[extras]
|
||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||
|
@ -11,6 +11,7 @@ import Base: findfirst, findnext, findlast, findprev, replace
|
||||
import Base: deepcopy_internal
|
||||
|
||||
using LinearAlgebra
|
||||
using ThreadsX
|
||||
|
||||
export gens, FreeGroup, Aut, SAut
|
||||
|
||||
@ -46,9 +47,9 @@ end
|
||||
|
||||
function Base.show(io::IO, s::T) where {T<:GSymbol}
|
||||
if s.pow == 1
|
||||
print(io, string(s.id))
|
||||
print(io, string(s.id))
|
||||
else
|
||||
print(io, "$(s.id)^$(s.pow)")
|
||||
print(io, "$(s.id)^$(s.pow)")
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,11 +73,18 @@ word-length metric on the group generated by `S`. The ball is centered at `cente
|
||||
radius and multiplication operation to be used.
|
||||
"""
|
||||
|
||||
function wlmetric_ball_serial(S::AbstractVector{T}; radius=2, op=*) where T<:Union{GroupElem, NCRingElem}
|
||||
function wlmetric_ball_serial(
|
||||
S::AbstractVector{T};
|
||||
radius = 2,
|
||||
op = *,
|
||||
) where {T<:Union{GroupElem,NCRingElem}}
|
||||
old = unique!([one(first(S)), S...])
|
||||
sizes = [1, length(old)]
|
||||
for i in 2:radius
|
||||
new = collect(op(i,j) for (i,j) in Base.product(@view(old[sizes[end-1]:end]), S))
|
||||
for i = 2:radius
|
||||
new = collect(
|
||||
op(i, j)
|
||||
for (i, j) in Base.product(@view(old[sizes[end-1]:end]), S)
|
||||
)
|
||||
append!(old, new)
|
||||
resize!(new, 0)
|
||||
old = unique!(old)
|
||||
@ -85,12 +93,18 @@ function wlmetric_ball_serial(S::AbstractVector{T}; radius=2, op=*) where T<:Uni
|
||||
return old, sizes[2:end]
|
||||
end
|
||||
|
||||
function wlmetric_ball_thr(S::AbstractVector{T}; radius=2, op=*) where T<:Union{GroupElem, NCRingElem}
|
||||
function wlmetric_ball_thr(
|
||||
S::AbstractVector{T};
|
||||
radius = 2,
|
||||
op = *,
|
||||
) where {T<:Union{GroupElem,NCRingElem}}
|
||||
old = unique!([one(first(S)), S...])
|
||||
sizes = [1, length(old)]
|
||||
for r in 2:radius
|
||||
for r = 2:radius
|
||||
begin
|
||||
new = ThreadsX.collect(op(o, s) for o in @view(old[sizes[end-1]:end]) for s in S)
|
||||
new = ThreadsX.collect(
|
||||
op(o, s) for o in @view(old[sizes[end-1]:end]) for s in S
|
||||
)
|
||||
ThreadsX.foreach(hash, new)
|
||||
end
|
||||
append!(old, new)
|
||||
@ -101,22 +115,37 @@ function wlmetric_ball_thr(S::AbstractVector{T}; radius=2, op=*) where T<:Union{
|
||||
return old, sizes[2:end]
|
||||
end
|
||||
|
||||
function wlmetric_ball_serial(S::AbstractVector{T}, center::T; radius=2, op=*) where T<:Union{GroupElem, NCRingElem}
|
||||
E, sizes = metric_ball_serial(S, radius=radius, op=op)
|
||||
function wlmetric_ball_serial(
|
||||
S::AbstractVector{T},
|
||||
center::T;
|
||||
radius = 2,
|
||||
op = *,
|
||||
) where {T<:Union{GroupElem,NCRingElem}}
|
||||
E, sizes = wlmetric_ball_serial(S, radius = radius, op = op)
|
||||
isone(center) && return E, sizes
|
||||
return c.*E, sizes
|
||||
return c .* E, sizes
|
||||
end
|
||||
|
||||
function wlmetric_ball_thr(S::AbstractVector{T}, center::T, radius=2, op=*) where T<:Union{GroupElem, NCRingElem}
|
||||
E, sizes = metric_ball_thr(S, radius=radius, op=op)
|
||||
function wlmetric_ball_thr(
|
||||
S::AbstractVector{T},
|
||||
center::T;
|
||||
radius = 2,
|
||||
op = *,
|
||||
) where {T<:Union{GroupElem,NCRingElem}}
|
||||
E, sizes = wlmetric_ball_thr(S, radius = radius, op = op)
|
||||
isone(center) && return E, sizes
|
||||
return c.*E, sizes
|
||||
return c .* E, sizes
|
||||
end
|
||||
|
||||
function wlmetric_ball(S::AbstractVector{T}, center::T=one(first(S);
|
||||
radius=2, op=*, threading=true)
|
||||
threading && return wlmetric_ball_thr(S, center, radius=radius, op=op)
|
||||
return return wlmetric_ball_serial(S, center, radius=radius, op=op)
|
||||
function wlmetric_ball(
|
||||
S::AbstractVector{T},
|
||||
center::T = one(first(S));
|
||||
radius = 2,
|
||||
op = *,
|
||||
threading = true,
|
||||
) where {T<:Union{GroupElem,NCRingElem}}
|
||||
threading && return wlmetric_ball_thr(S, center, radius = radius, op = op)
|
||||
return return wlmetric_ball_serial(S, center, radius = radius, op = op)
|
||||
end
|
||||
|
||||
"""
|
||||
@ -127,9 +156,11 @@ Evaluate homomorphism `homomorphism` on a group word (element) `w`.
|
||||
where `hom(;kwargs...)` returns the value at the identity element.
|
||||
"""
|
||||
function image(w::GWord, hom; kwargs...)
|
||||
return reduce(*,
|
||||
return reduce(
|
||||
*,
|
||||
(hom(s; kwargs...) for s in syllables(w)),
|
||||
init = hom(;kwargs...))
|
||||
init = hom(; kwargs...),
|
||||
)
|
||||
end
|
||||
|
||||
end # of module Groups
|
||||
|
Loading…
Reference in New Issue
Block a user