mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 02:05:30 +01:00
formatting
This commit is contained in:
parent
5752d67009
commit
29e2097f2f
@ -6,7 +6,7 @@ function gersten_alphabet(n::Integer; commutative::Bool = true)
|
||||
append!(S, [λ(i, j) for (i, j) in indexing])
|
||||
end
|
||||
|
||||
return Alphabet(S)
|
||||
return Alphabet(mapreduce(x -> [x, inv(x)], union, S))
|
||||
end
|
||||
|
||||
function _commutation_rule(
|
||||
@ -46,7 +46,7 @@ gersten_relations(n::Integer; commutative) =
|
||||
function gersten_relations(::Type{W}, n::Integer; commutative) where {W<:AbstractWord}
|
||||
@assert n > 1 "Gersten relations are defined only for n>1, got n=$n"
|
||||
A = gersten_alphabet(n, commutative=commutative)
|
||||
@assert length(A) <= KnuthBendix._max_alphabet_length(W) "Type $W can not represent words over alphabet with $(length(A)) letters."
|
||||
@assert length(A) <= typemax(eltype(W)) "Type $W can not represent words over alphabet with $(length(A)) letters."
|
||||
|
||||
rels = Pair{W,W}[]
|
||||
|
||||
|
@ -17,7 +17,7 @@ function Base.show(io::IO, S::SurfaceGroup)
|
||||
end
|
||||
end
|
||||
|
||||
function SurfaceGroup(genus::Integer, boundaries::Integer)
|
||||
function SurfaceGroup(genus::Integer, boundaries::Integer, W=Word{Int16})
|
||||
@assert genus > 1
|
||||
|
||||
# The (confluent) rewriting systems comes from
|
||||
@ -37,8 +37,8 @@ function SurfaceGroup(genus::Integer, boundaries::Integer)
|
||||
|
||||
for i in 1:genus
|
||||
subscript = join('₀' + d for d in reverse(digits(i)))
|
||||
KnuthBendix.set_inversion!(Al, "a" * subscript, "A" * subscript)
|
||||
KnuthBendix.set_inversion!(Al, "b" * subscript, "B" * subscript)
|
||||
KnuthBendix.setinverse!(Al, "a" * subscript, "A" * subscript)
|
||||
KnuthBendix.setinverse!(Al, "b" * subscript, "B" * subscript)
|
||||
end
|
||||
|
||||
if boundaries == 0
|
||||
@ -48,7 +48,7 @@ function SurfaceGroup(genus::Integer, boundaries::Integer)
|
||||
x = 4 * i
|
||||
append!(word, [x, x - 2, x - 1, x - 3])
|
||||
end
|
||||
comms = Word(word)
|
||||
comms = W(word)
|
||||
word_rels = [comms => one(comms)]
|
||||
|
||||
rws = let R = KnuthBendix.RewritingSystem(word_rels, KnuthBendix.Recursive(Al))
|
||||
@ -60,10 +60,10 @@ function SurfaceGroup(genus::Integer, boundaries::Integer)
|
||||
KnuthBendix.IndexAutomaton(KnuthBendix.knuthbendix(R))
|
||||
end
|
||||
else
|
||||
throw("Not Implemented")
|
||||
throw("Not Implemented for MCG with $boundaryies boundary components")
|
||||
end
|
||||
|
||||
F = FreeGroup(alphabet(rws))
|
||||
F = FreeGroup(Al)
|
||||
rels = [F(lhs) => F(rhs) for (lhs, rhs) in word_rels]
|
||||
|
||||
return SurfaceGroup(genus, boundaries, [Al[i] for i in 2:2:length(Al)], rels, rws)
|
||||
|
@ -188,7 +188,7 @@ function SymplecticMappingClass(
|
||||
i::Integer,
|
||||
j::Integer;
|
||||
minus=false,
|
||||
inverse = false,
|
||||
inverse=false
|
||||
)
|
||||
@assert i > 0 && j > 0
|
||||
id === :A && @assert i ≠ j
|
||||
|
@ -207,7 +207,8 @@ function generated_evaluate(a::FPGroupElement{<:AutomorphismGroup})
|
||||
@assert length(v.args) >= 2
|
||||
if length(v.args) > 2
|
||||
for (j, a) in pairs(v.args)
|
||||
if a isa Expr && a.head == :call "$a"
|
||||
if a isa Expr && a.head == :call
|
||||
"$a"
|
||||
@assert a.args[1] == :inv
|
||||
if !(a in keys(locals))
|
||||
locals[a] = Symbol("var_#$locals_counter")
|
||||
|
@ -5,7 +5,7 @@ struct SpecialLinearGroup{N, T, R, A, S} <: MatrixGroup{N,T}
|
||||
alphabet::A
|
||||
gens::S
|
||||
|
||||
function SpecialLinearGroup{N}(base_ring) where N
|
||||
function SpecialLinearGroup{N}(base_ring) where {N}
|
||||
S = [ElementaryMatrix{N}(i, j, one(base_ring)) for i in 1:N for j in 1:N if i ≠ j]
|
||||
alphabet = Alphabet(S)
|
||||
|
||||
@ -19,7 +19,7 @@ struct SpecialLinearGroup{N, T, R, A, S} <: MatrixGroup{N,T}
|
||||
end
|
||||
end
|
||||
|
||||
GroupsCore.ngens(SL::SpecialLinearGroup{N}) where N = N^2 - N
|
||||
GroupsCore.ngens(SL::SpecialLinearGroup{N}) where {N} = N^2 - N
|
||||
|
||||
Base.show(io::IO, SL::SpecialLinearGroup{N,T}) where {N,T} =
|
||||
print(io, "special linear group of $N×$N matrices over $T")
|
||||
@ -28,7 +28,7 @@ function Base.show(
|
||||
io::IO,
|
||||
::MIME"text/plain",
|
||||
sl::Groups.AbstractFPGroupElement{<:SpecialLinearGroup{N}}
|
||||
) where N
|
||||
) where {N}
|
||||
|
||||
Groups.normalform!(sl)
|
||||
|
||||
|
@ -5,7 +5,7 @@ struct SymplecticGroup{N, T, R, A, S} <: MatrixGroup{N,T}
|
||||
alphabet::A
|
||||
gens::S
|
||||
|
||||
function SymplecticGroup{N}(base_ring) where N
|
||||
function SymplecticGroup{N}(base_ring) where {N}
|
||||
S = symplectic_gens(N, eltype(base_ring))
|
||||
alphabet = Alphabet(S)
|
||||
|
||||
@ -21,7 +21,7 @@ end
|
||||
|
||||
GroupsCore.ngens(Sp::SymplecticGroup) = length(Sp.gens)
|
||||
|
||||
Base.show(io::IO, ::SymplecticGroup{N}) where N = print(io, "group of $N×$N symplectic matrices")
|
||||
Base.show(io::IO, ::SymplecticGroup{N}) where {N} = print(io, "group of $N×$N symplectic matrices")
|
||||
|
||||
function Base.show(
|
||||
io::IO,
|
||||
@ -65,6 +65,6 @@ function _std_symplectic_form(m::AbstractMatrix)
|
||||
return Ω
|
||||
end
|
||||
|
||||
function issymplectic(mat::M, Ω = _std_symplectic_form(mat)) where M <: AbstractMatrix
|
||||
function issymplectic(mat::M, Ω=_std_symplectic_form(mat)) where {M<:AbstractMatrix}
|
||||
return Ω == transpose(mat) * Ω * mat
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ function Base.:(==)(m1::M1, m2::M2) where {M1<:MatrixGroupElement, M2<:MatrixGro
|
||||
return matrix_repr(m1) == matrix_repr(m2)
|
||||
end
|
||||
|
||||
Base.size(m::MatrixGroupElement{N}) where N = (N, N)
|
||||
Base.size(m::MatrixGroupElement{N}) where {N} = (N, N)
|
||||
Base.eltype(m::MatrixGroupElement{N,T}) where {N,T} = T
|
||||
|
||||
# three structural assumptions about matrix groups
|
||||
|
@ -2,7 +2,7 @@ struct ElementaryMatrix{N, T} <: Groups.GSymbol
|
||||
i::Int
|
||||
j::Int
|
||||
val::T
|
||||
ElementaryMatrix{N}(i, j, val=1) where N =
|
||||
ElementaryMatrix{N}(i, j, val=1) where {N} =
|
||||
(@assert i ≠ j; new{N,typeof(val)}(i, j, val))
|
||||
end
|
||||
|
||||
@ -11,13 +11,13 @@ function Base.show(io::IO, e::ElementaryMatrix)
|
||||
!isone(e.val) && print(io, "^$(e.val)")
|
||||
end
|
||||
|
||||
Base.:(==)(e::ElementaryMatrix{N}, f::ElementaryMatrix{N}) where N =
|
||||
Base.:(==)(e::ElementaryMatrix{N}, f::ElementaryMatrix{N}) where {N} =
|
||||
e.i == f.i && e.j == f.j && e.val == f.val
|
||||
|
||||
Base.hash(e::ElementaryMatrix, h::UInt) =
|
||||
hash(typeof(e), hash((e.i, e.j, e.val), h))
|
||||
|
||||
Base.inv(e::ElementaryMatrix{N}) where N =
|
||||
Base.inv(e::ElementaryMatrix{N}) where {N} =
|
||||
ElementaryMatrix{N}(e.i, e.j, -e.val)
|
||||
|
||||
function matrix_repr(e::ElementaryMatrix{N,T}) where {N,T}
|
||||
|
@ -3,7 +3,7 @@ struct ElementarySymplectic{N, T} <: Groups.GSymbol
|
||||
i::Int
|
||||
j::Int
|
||||
val::T
|
||||
function ElementarySymplectic{N}(s::Symbol, i::Integer, j::Integer, val=1) where N
|
||||
function ElementarySymplectic{N}(s::Symbol, i::Integer, j::Integer, val=1) where {N}
|
||||
@assert s ∈ (:A, :B)
|
||||
@assert iseven(N)
|
||||
n = N ÷ 2
|
||||
@ -22,9 +22,9 @@ function Base.show(io::IO, s::ElementarySymplectic)
|
||||
!isone(s.val) && print(io, "^$(s.val)")
|
||||
end
|
||||
|
||||
_ind(s::ElementarySymplectic{N}) where N = (s.i, s.j)
|
||||
_ind(s::ElementarySymplectic{N}) where {N} = (s.i, s.j)
|
||||
_local_ind(N_half::Integer, i::Integer) = ifelse(i <= N_half, i, i - N_half)
|
||||
function _dual_ind(s::ElementarySymplectic{N}) where N
|
||||
function _dual_ind(s::ElementarySymplectic{N}) where {N}
|
||||
if s.symbol === :A && return _ind(s)
|
||||
else#if s.symbol === :B
|
||||
return _dual_ind(N ÷ 2, s.i, s.j)
|
||||
@ -51,10 +51,10 @@ end
|
||||
Base.hash(s::ElementarySymplectic, h::UInt) =
|
||||
hash(Set([_ind(s); _dual_ind(s)]), hash(s.symbol, hash(s.val, h)))
|
||||
|
||||
LinearAlgebra.transpose(s::ElementarySymplectic{N}) where N =
|
||||
LinearAlgebra.transpose(s::ElementarySymplectic{N}) where {N} =
|
||||
ElementarySymplectic{N}(s.symbol, s.j, s.i, s.val)
|
||||
|
||||
Base.inv(s::ElementarySymplectic{N}) where N =
|
||||
Base.inv(s::ElementarySymplectic{N}) where {N} =
|
||||
ElementarySymplectic{N}(s.symbol, s.i, s.j, -s.val)
|
||||
|
||||
function matrix_repr(s::ElementarySymplectic{N,T}) where {N,T}
|
||||
|
@ -223,7 +223,7 @@ function FPGroup(
|
||||
G::AbstractFPGroup,
|
||||
rels::AbstractVector{<:Pair{GEl,GEl}};
|
||||
ordering=KnuthBendix.ordering(G),
|
||||
kwargs...,
|
||||
kwargs...
|
||||
) where {GEl<:FPGroupElement}
|
||||
for (lhs, rhs) in rels
|
||||
@assert parent(lhs) === parent(rhs) === G
|
||||
|
@ -1,11 +1,22 @@
|
||||
"""
|
||||
wlmetric_ball(S::AbstractVector{<:GroupElem}
|
||||
[, center=one(first(S)); radius=2, op=*])
|
||||
[, center=one(first(S)); radius=2, op=*, threading=true])
|
||||
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.
|
||||
"""
|
||||
function wlmetric_ball(
|
||||
S::AbstractVector{T},
|
||||
center::T=one(first(S));
|
||||
radius=2,
|
||||
op=*,
|
||||
threading=true
|
||||
) where {T}
|
||||
threading && return wlmetric_ball_thr(S, center, radius=radius, op=op)
|
||||
return wlmetric_ball_serial(S, center, radius=radius, op=op)
|
||||
end
|
||||
|
||||
function wlmetric_ball_serial(S::AbstractVector{T}, center::T=one(first(S)); radius=2, op=*) where {T}
|
||||
@assert radius >= 1
|
||||
old = union!([center], [center * s for s in S])
|
||||
@ -26,6 +37,7 @@ function _wlmetric_ball(S, old, radius, op, collect, unique)
|
||||
(g = op(o, s); hash(g); g)
|
||||
for o in @view(old[sizes[end-1]:end]) for s in S
|
||||
)
|
||||
|
||||
append!(old, new)
|
||||
unique(old)
|
||||
end
|
||||
@ -34,13 +46,3 @@ function _wlmetric_ball(S, old, radius, op, collect, unique)
|
||||
return old, sizes[2:end]
|
||||
end
|
||||
|
||||
function wlmetric_ball(
|
||||
S::AbstractVector{T},
|
||||
center::T = one(first(S));
|
||||
radius = 2,
|
||||
op = *,
|
||||
threading = true,
|
||||
) where {T}
|
||||
threading && return wlmetric_ball_thr(S, center, radius = radius, op = op)
|
||||
return wlmetric_ball_serial(S, center, radius = radius, op = op)
|
||||
end
|
||||
|
@ -91,12 +91,12 @@
|
||||
|
||||
@testset "Automorphisms: hash and evaluate" begin
|
||||
@test Groups.domain(gens(A, 1)) == D
|
||||
g, h = gens(A, 1), gens(A, 8)
|
||||
g, h = gens(A, 1), gens(A, 8) # (ϱ₁.₂, ϱ₃.₂)
|
||||
|
||||
@test evaluate(g * h) == evaluate(h * g)
|
||||
@test (g * h).savedhash == zero(UInt)
|
||||
|
||||
@test sprint(show, typeof(g)) == "Automorphism{FreeGroup{Symbol, KnuthBendix.LenLex{Symbol}}, …}"
|
||||
@test contains(sprint(show, typeof(g)), "Automorphism{FreeGroup{Symbol")
|
||||
|
||||
a = g * h
|
||||
b = h * g
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
π₁Σ = Groups.SurfaceGroup(genus, 0)
|
||||
|
||||
@test contains(sprint(print, π₁Σ), "surface")
|
||||
|
||||
Groups.PermRightAut(p::Perm) = Groups.PermRightAut(p.d)
|
||||
# Groups.PermLeftAut(p::Perm) = Groups.PermLeftAut(p.d)
|
||||
autπ₁Σ = let autπ₁Σ = AutomorphismGroup(π₁Σ)
|
||||
|
@ -4,9 +4,10 @@ using Groups.MatrixGroups
|
||||
@testset "SL(n, ℤ)" begin
|
||||
SL3Z = SpecialLinearGroup{3}(Int8)
|
||||
|
||||
S = gens(SL3Z); union!(S, inv.(S))
|
||||
S = gens(SL3Z)
|
||||
union!(S, inv.(S))
|
||||
|
||||
E, sizes = Groups.wlmetric_ball(S, radius=4)
|
||||
_, sizes = Groups.wlmetric_ball(S, radius=4)
|
||||
|
||||
@test sizes == [13, 121, 883, 5455]
|
||||
|
||||
@ -17,10 +18,11 @@ using Groups.MatrixGroups
|
||||
r = E(2, 3)^-3
|
||||
s = E(1, 3)^2 * E(3, 2)^-1
|
||||
|
||||
S = [w,r,s]; S = unique([S; inv.(S)]);
|
||||
_, sizes = Groups.wlmetric_ball(S, radius=4);
|
||||
S = [w, r, s]
|
||||
S = unique([S; inv.(S)])
|
||||
_, sizes = Groups.wlmetric_ball(S, radius=4)
|
||||
@test sizes == [7, 33, 141, 561]
|
||||
_, sizes = Groups.wlmetric_ball_serial(S, radius=4);
|
||||
_, sizes = Groups.wlmetric_ball_serial(S, radius=4)
|
||||
@test sizes == [7, 33, 141, 561]
|
||||
|
||||
Logging.with_logger(Logging.NullLogger()) do
|
||||
@ -50,6 +52,7 @@ using Groups.MatrixGroups
|
||||
@testset "Sp(6, ℤ)" begin
|
||||
Sp6 = MatrixGroups.SymplecticGroup{6}(Int8)
|
||||
|
||||
Logging.with_logger(Logging.NullLogger()) do
|
||||
@testset "GroupsCore conformance" begin
|
||||
test_Group_interface(Sp6)
|
||||
g = Sp6(rand(1:length(alphabet(Sp6)), 10))
|
||||
@ -57,6 +60,7 @@ using Groups.MatrixGroups
|
||||
|
||||
test_GroupElement_interface(g, h)
|
||||
end
|
||||
end
|
||||
|
||||
@test contains(sprint(print, Sp6), "group of 6×6 symplectic matrices")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user