From 6774d40d11200ae1604c4fca9fdc8a2e2a13e6e4 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Sun, 3 Apr 2022 16:58:49 +0200 Subject: [PATCH] more coverage: MatrixGroups --- src/matrix_groups/Spn.jl | 4 ++-- src/matrix_groups/abstract.jl | 4 ---- src/matrix_groups/eltary_symplectic.jl | 6 ------ test/matrix_groups.jl | 27 ++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/matrix_groups/Spn.jl b/src/matrix_groups/Spn.jl index 630a56a..ba7c8c5 100644 --- a/src/matrix_groups/Spn.jl +++ b/src/matrix_groups/Spn.jl @@ -28,8 +28,8 @@ function Base.show( ::MIME"text/plain", sp::Groups.AbstractFPGroupElement{<:SymplecticGroup{N}} ) where {N} - normalform!(sp) - print(io, "$N×$N Symplectic matrix: ") + Groups.normalform!(sp) + print(io, "$N×$N symplectic matrix: ") KnuthBendix.print_repr(io, word(sp), alphabet(sp)) println(io) Base.print_array(io, matrix_repr(sp)) diff --git a/src/matrix_groups/abstract.jl b/src/matrix_groups/abstract.jl index 5e19c86..1a4cf1f 100644 --- a/src/matrix_groups/abstract.jl +++ b/src/matrix_groups/abstract.jl @@ -22,10 +22,6 @@ Groups.rewriting(M::MatrixGroup) = alphabet(M) Base.hash(sl::MatrixGroupElement, h::UInt) = hash(matrix_repr(sl), hash(parent(sl), h)) -Base.getindex(sl::MatrixGroupElement, i, j) = matrix_repr(sl)[i,j] -# Base.iterate(sl::MatrixGroupElement) = iterate(sl.elts) -# Base.iterate(sl::MatrixGroupElement, state) = iterate(sl.elts, state) - function matrix_repr(m::MatrixGroupElement{N, T}) where {N, T} if isone(word(m)) return StaticArrays.SMatrix{N, N, T}(LinearAlgebra.I) diff --git a/src/matrix_groups/eltary_symplectic.jl b/src/matrix_groups/eltary_symplectic.jl index dba3b43..c1d3d68 100644 --- a/src/matrix_groups/eltary_symplectic.jl +++ b/src/matrix_groups/eltary_symplectic.jl @@ -22,12 +22,6 @@ function Base.show(io::IO, s::ElementarySymplectic) !isone(s.val) && print(io, "^$(s.val)") end -function Base.show(io::IO, ::MIME"text/plain", s::ElementarySymplectic) - print(io, s) - print(io, " → corresponding root: ") - print(io, Roots.Root(s)) -end - _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 diff --git a/test/matrix_groups.jl b/test/matrix_groups.jl index 92555b2..d882215 100644 --- a/test/matrix_groups.jl +++ b/test/matrix_groups.jl @@ -32,6 +32,19 @@ using Groups.MatrixGroups test_GroupElement_interface(g, h) end end + + + x = w*inv(w)*r + + @test length(word(x)) == 5 + @test size(x) == (3,3) + @test eltype(x) == Int8 + + @test contains(sprint(print, SL3Z), "special linear group of 3×3") + @test contains(sprint(show, MIME"text/plain"(), x), "SL{3,Int8} matrix:") + @test sprint(print, x) isa String + + @test length(word(x)) == 3 end @testset "Sp(6, ℤ)" begin @@ -44,5 +57,19 @@ using Groups.MatrixGroups test_GroupElement_interface(g, h) end + + @test contains(sprint(print, Sp6), "group of 6×6 symplectic matrices") + + x = gens(Sp6, 1) + x *= inv(x) * gens(Sp6, 2) + + @test length(word(x)) == 3 + @test size(x) == (6,6) + @test eltype(x) == Int8 + + @test contains(sprint(show, MIME"text/plain"(), x), "6×6 symplectic matrix:") + @test sprint(print, x) isa String + + @test length(word(x)) == 1 end end