some eye-candy

This commit is contained in:
Marek Kaluba 2021-06-07 20:25:39 +02:00
parent 66a33e7c72
commit 979ffaccfa
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 22 additions and 9 deletions

View File

@ -84,6 +84,17 @@ Base.show(io::IO, ::Type{<:FPGroupElement{<:AutomorphismGroup{T}}}) where {T} =
Base.show(io::IO, A::AutomorphismGroup) = print(io, "automorphism group of ", object(A))
function Base.show(io::IO, ::MIME"text/plain", a::FPGroupElement{<:AutomorphismGroup})
println(io, "$(a):")
im = evaluate(a)
d = domain(a)
for (x, imx) in zip(d, im[1:end-1])
println(io, "$x$imx")
end
print(io, "$(last(d))$(last(im))")
end
## Automorphism Evaluation
domain(f::FPGroupElement{<:AutomorphismGroup}) = deepcopy(parent(f).domain)

View File

@ -36,6 +36,14 @@ Base.@propagate_inbounds function (G::AbstractFPGroup)(word::AbstractVector{<:In
return FPGroupElement(word_type(G)(word), G)
end
function Base.show(io::IO, G::AbstractFPGroup)
print(io, "")
join(io, gens(G), ", ")
print(io, " | ")
join(io, relations(G), ", ")
print(io, "")
end
## Group Interface
Base.one(G::AbstractFPGroup) = FPGroupElement(one(word_type(G)), G)
@ -140,7 +148,7 @@ function FreeGroup(n::Integer)
sizehint!(symbols, 2n)
sizehint!(inverses, 2n)
for i in 1:n
push!(symbols, Symbol(:f, i), Symbol(:F, i))
push!(symbols, Symbol(:f, subscriptify(i)), Symbol(:F, subscriptify(i)))
push!(inverses, 2i, 2i-1)
end
return FreeGroup(symbols[1:2:2n], Alphabet(symbols, inverses))
@ -190,15 +198,9 @@ function FPGroup(
return FPGroup(G.gens, rels, rws)
end
function Base.show(io::IO, G::FPGroup)
print(io, "")
join(io, gens(G), ", ")
print(io, " | ")
join(io, relations(G), ", ")
print(io, "")
end
## GSymbol aka letter of alphabet
abstract type GSymbol end
Base.literal_pow(::typeof(^), t::GSymbol, ::Val{-1}) = inv(t)
subscriptify(i::Integer) = join('₀'+d for d in reverse(digits(i)))