move show functions to abstract.jl

This commit is contained in:
Marek Kaluba 2023-03-15 17:20:52 +01:00
parent a380959614
commit 116439d074
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 35 additions and 26 deletions

View File

@ -21,22 +21,14 @@ end
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")
function Base.show(io::IO, ::SpecialLinearGroup{N,T}) where {N,T}
return print(io, "SL{$N,$T}")
end
function Base.show(
io::IO,
::MIME"text/plain",
sl::Groups.AbstractFPGroupElement{<:SpecialLinearGroup{N}}
) where {N}
Groups.normalform!(sl)
print(io, "SL{$N,$(eltype(sl))} matrix: ")
KnuthBendix.print_repr(io, word(sl), alphabet(sl))
println(io)
Base.print_array(io, matrix_repr(sl))
SL::SpecialLinearGroup{N,T},
) where {N,T}
return print(io, "special linear group of $N×$N matrices over $T")
end
Base.show(io::IO, sl::Groups.AbstractFPGroupElement{<:SpecialLinearGroup}) =
KnuthBendix.print_repr(io, word(sl), alphabet(sl))

View File

@ -21,20 +21,11 @@ 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,T}) where {N,T} = print(io, "Sp{$N,$T}")
function Base.show(
io::IO,
::MIME"text/plain",
sp::Groups.AbstractFPGroupElement{<:SymplecticGroup{N}}
) where {N}
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))
function Base.show(io::IO, ::MIME"text/plain", ::SymplecticGroup{N}) where {N}
return print(io, "group of $N×$N symplectic matrices")
end
_offdiag_idcs(n) = ((i, j) for i in 1:n for j in 1:n if i j)
function symplectic_gens(N, T=Int8)

View File

@ -38,3 +38,29 @@ function Base.rand(
S = gens(Mgroup)
return prod(g -> rand(rng, Bool) ? g : inv(g), rand(rng, S, rand(rng, 1:30)))
end
function Base.show(io::IO, M::AbstractMatrixGroup)
g = gens(M, 1)
N = size(g, 1)
print(io, "H ⩽ GL{$N,$(eltype(g))}")
end
function Base.show(io::IO, ::MIME"text/plain", M::AbstractMatrixGroup)
N = size(gens(M, 1), 1)
ng = GroupsCore.ngens(M)
print(io, "subgroup of $N×$N invertible matrices with $(ng) generators")
end
Base.show(io::IO, mat::Groups.AbstractFPGroupElement{<:AbstractMatrixGroup}) =
KnuthBendix.print_repr(io, word(mat), alphabet(mat))
function Base.show(
io::IO,
::MIME"text/plain",
mat::Groups.AbstractFPGroupElement{<:AbstractMatrixGroup{N}}
) where {N}
Groups.normalform!(mat)
KnuthBendix.print_repr(io, word(mat), alphabet(mat))
println(io, "", parent(mat))
Base.print_array(io, matrix(mat))
end