more coverage: MatrixGroups

This commit is contained in:
Marek Kaluba 2022-04-03 16:58:49 +02:00
parent c9a4b00ceb
commit 6774d40d11
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
4 changed files with 29 additions and 12 deletions

View File

@ -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))

View File

@ -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)

View File

@ -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

View File

@ -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