Skip to content

Commit

Permalink
Print group generators in detailed printing
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jan 19, 2024
1 parent f1f060f commit 13d13fa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/Groups/GAPGroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,26 @@ function Base.show(io::IO, G::PcGroup)
end
end

function Base.show(io::IO, ::MIME"text/plain", x::GAPGroup)
# Recurse to regular printing
print(io, x)
has_gens(x) || return
println(io)
io = pretty(io)
n = ngens(x)
println(io, "with ", ItemQuantity(n, "generator"))
print(io, Indent())
# TODO: can we do something similar to what `show` for vectors does and
# restrict this to fill one screen by default?
for (i, g) in enumerate(gens(x))
show(io, MIME"text/plain"(), g)
if i < n
println(io)
end
end
print(io, Dedent())
end


Base.isone(x::GAPGroupElem) = GAPWrap.IsOne(x.X)

Expand Down
18 changes: 16 additions & 2 deletions src/Groups/matrices/MatGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,23 @@ end
function Base.show(io::IO, ::MIME"text/plain", x::MatrixGroup)
isdefined(x, :descr) && return _print_matrix_group_desc(io, x)
println(io, "Matrix group of degree ", degree(x))
io = AbstractAlgebra.pretty(io)
io = pretty(io)
print(io, Indent())
print(io, "over ", Lowercase(), base_ring(x))
println(io, "over ", Lowercase(), base_ring(x))
print(io, Dedent())
has_gens(x) || return
n = ngens(x)
println(io, "with ", ItemQuantity(n, "generator"))
print(io, Indent())
# TODO: can we do something similar to what `show` for vectors does and
# restrict this to fill one screen by default?
for (i, g) in enumerate(gens(x))
show(io, MIME"text/plain"(), g)
if i < n
println(io)
println(io)
end
end
print(io, Dedent())
end

Expand Down

0 comments on commit 13d13fa

Please sign in to comment.