1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 22:40:28 +01:00
Groups.jl/test/matrix_groups.jl

120 lines
3.5 KiB
Julia
Raw Normal View History

using Groups.MatrixGroups
@testset "Matrix Groups" begin
@testset "SL(n, )" begin
SL3Z = SpecialLinearGroup{3}(Int8)
2022-10-14 01:14:38 +02:00
S = gens(SL3Z)
union!(S, inv.(S))
2023-03-15 18:28:10 +01:00
_, sizes = Groups.wlmetric_ball(S; radius = 4)
2022-04-02 14:53:06 +02:00
@test sizes == [13, 121, 883, 5455]
2022-10-14 01:14:38 +02:00
E(i, j) = SL3Z([A[MatrixGroups.ElementaryMatrix{3}(i, j, Int8(1))]])
2022-04-02 14:53:06 +02:00
A = alphabet(SL3Z)
2022-10-14 01:14:38 +02:00
w = E(1, 2)
r = E(2, 3)^-3
s = E(1, 3)^2 * E(3, 2)^-1
2022-04-02 14:53:06 +02:00
2022-10-14 01:14:38 +02:00
S = [w, r, s]
S = unique([S; inv.(S)])
2023-03-15 18:28:10 +01:00
_, sizes = Groups.wlmetric_ball(S; radius = 4)
2022-04-02 14:53:06 +02:00
@test sizes == [7, 33, 141, 561]
2022-04-02 15:51:29 +02:00
Logging.with_logger(Logging.NullLogger()) do
@testset "GroupsCore conformance" begin
test_Group_interface(SL3Z)
g = SL3Z(rand(1:length(alphabet(SL3Z)), 10))
h = SL3Z(rand(1:length(alphabet(SL3Z)), 10))
test_GroupElement_interface(g, h)
end
end
2022-04-03 16:58:49 +02:00
2023-03-22 21:44:09 +01:00
x = w * inv(SL3Z(word(w)[end:end])) * r
2022-04-03 16:58:49 +02:00
2023-03-22 21:44:09 +01:00
@test length(word(x)) == length(word(r))
2022-10-14 01:14:38 +02:00
@test size(x) == (3, 3)
2022-04-03 16:58:49 +02:00
@test eltype(x) == Int8
2023-03-15 18:28:10 +01:00
@test contains(sprint(show, SL3Z), "SL{3,Int8}")
@test contains(
sprint(show, MIME"text/plain"(), SL3Z),
"special linear group",
)
@test contains(sprint(show, MIME"text/plain"(), x), "∈ SL{3,Int8}")
2022-04-03 16:58:49 +02:00
@test sprint(print, x) isa String
@test length(word(x)) == 3
end
2022-04-02 16:19:08 +02:00
@testset "Sp(6, )" begin
Sp6 = MatrixGroups.SymplecticGroup{6}(Int8)
2022-10-14 01:14:38 +02:00
Logging.with_logger(Logging.NullLogger()) do
@testset "GroupsCore conformance" begin
test_Group_interface(Sp6)
g = Sp6(rand(1:length(alphabet(Sp6)), 10))
h = Sp6(rand(1:length(alphabet(Sp6)), 10))
2022-04-02 16:19:08 +02:00
2022-10-14 01:14:38 +02:00
test_GroupElement_interface(g, h)
end
2022-04-02 16:19:08 +02:00
end
2022-04-03 16:58:49 +02:00
2023-03-22 21:44:09 +01:00
x = gens(Sp6, 1) * gens(Sp6, 2)^2
x *= inv(gens(Sp6, 2)^2) * gens(Sp6, 3)
2022-04-03 16:58:49 +02:00
2023-03-22 21:44:09 +01:00
@test length(word(x)) == 2
2022-10-14 01:14:38 +02:00
@test size(x) == (6, 6)
2022-04-03 16:58:49 +02:00
@test eltype(x) == Int8
2023-03-15 18:28:10 +01:00
@test contains(sprint(show, Sp6), "Sp{6,Int8}")
@test contains(
sprint(show, MIME"text/plain"(), Sp6),
"group of 6×6 symplectic matrices",
)
@test contains(sprint(show, MIME"text/plain"(), x), "∈ Sp{6,Int8}")
2022-04-03 16:58:49 +02:00
@test sprint(print, x) isa String
2023-03-22 21:44:09 +01:00
@test length(word(x)) == 2
2022-04-03 18:40:02 +02:00
for g in gens(Sp6)
2023-03-15 18:28:10 +01:00
@test MatrixGroups.issymplectic(MatrixGroups.matrix(g))
2022-04-03 18:40:02 +02:00
end
2022-04-02 16:19:08 +02:00
end
2023-03-15 18:30:55 +01:00
@testset "General matrix group" begin
Sp6 = MatrixGroups.SymplecticGroup{6}(Int8)
G = Groups.MatrixGroup{6}(Matrix{Int16}.(gens(Sp6)))
Logging.with_logger(Logging.NullLogger()) do
@testset "GroupsCore conformance" begin
test_Group_interface(G)
g = G(rand(1:length(alphabet(G)), 10))
h = G(rand(1:length(alphabet(G)), 10))
test_GroupElement_interface(g, h)
end
end
2023-03-22 21:44:09 +01:00
x = gens(G, 1) * gens(G, 2)^3
x *= gens(G, 2)^-3
2023-03-15 18:30:55 +01:00
2023-03-22 21:44:09 +01:00
@test length(word(x)) == 1
2023-03-15 18:30:55 +01:00
@test size(x) == (6, 6)
@test eltype(x) == Int16
@test contains(sprint(show, G), "H ⩽ GL{6,Int16}")
@test contains(
sprint(show, MIME"text/plain"(), G),
"subgroup of 6×6 invertible matrices",
)
@test contains(sprint(show, MIME"text/plain"(), x), "∈ H ⩽ GL{6,Int16}")
@test sprint(print, x) isa String
@test length(word(x)) == 1
end
end