Skip to content

Commit

Permalink
Some nicer printing
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Mar 5, 2024
1 parent a523e16 commit 121270d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 81 deletions.
58 changes: 18 additions & 40 deletions src/ModifyTable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,25 @@ Replace the parameter `var` with `expr` in the character type `char`.
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");
julia> printval(g,char=1)
Value of character type 1 on class type
1 (1) * exp(2π𝑖(2//(q - 1)*i*k))
2 (1) * exp(2π𝑖(2//(q - 1)*i*k))
3 (1) * exp(2π𝑖(1//(q - 1)*i*k + 1//(q - 1)*j*k))
4 (1) * exp(2π𝑖(1//(q - 1)*i*k))
1: (1) * exp(2π𝑖(2//(q - 1)*i*k))
2: (1) * exp(2π𝑖(2//(q - 1)*i*k))
3: (1) * exp(2π𝑖(1//(q - 1)*i*k + 1//(q - 1)*j*k))
4: (1) * exp(2π𝑖(1//(q - 1)*i*k))
julia> q,(i,j,l,k) = params(g);
julia> speccharparam!(g, 1, i, q)
julia> printval(g,char=1)
Value of character type 1 on class type
1 (1) * exp(2π𝑖(2//(q - 1)*k))
2 (1) * exp(2π𝑖(2//(q - 1)*k))
3 (1) * exp(2π𝑖(1//(q - 1)*j*k + 1//(q - 1)*k))
4 (1) * exp(2π𝑖(1//(q - 1)*k))
1: (1) * exp(2π𝑖(2//(q - 1)*k))
2: (1) * exp(2π𝑖(2//(q - 1)*k))
3: (1) * exp(2π𝑖(1//(q - 1)*j*k + 1//(q - 1)*k))
4: (1) * exp(2π𝑖(1//(q - 1)*k))
```
"""
function speccharparam!(t::CharTable{T}, char::Int64, var::FracPoly{T}, expr::RingElement) where T <: NfPoly
Expand All @@ -225,48 +220,31 @@ Replace the parameter `var` with `expr` in the class type `class`.
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");
julia> printval(g,class=1)
Value of character type 1 on class type
1 (1) * exp(2π𝑖(2//(q - 1)*i*k))
1: (1) * exp(2π𝑖(2//(q - 1)*i*k))
Value of character type 2 on class type
1 (q) * exp(2π𝑖(2//(q - 1)*i*k))
1: (q) * exp(2π𝑖(2//(q - 1)*i*k))
Value of character type 3 on class type
1 (q + 1) * exp(2π𝑖(1//(q - 1)*i*l + 1//(q - 1)*i*k))
1: (q + 1) * exp(2π𝑖(1//(q - 1)*i*l + 1//(q - 1)*i*k))
Value of character type 4 on class type
1 (q - 1) * exp(2π𝑖(1//(q - 1)*i*k))
1: (q - 1) * exp(2π𝑖(1//(q - 1)*i*k))
julia> q,(i,j,l,k) = params(g);
julia> specclassparam!(g, 1, k, 3)
julia> printval(g,class=1)
Value of character type 1 on class type
1 (1) * exp(2π𝑖(6//(q - 1)*i))
1: (1) * exp(2π𝑖(6//(q - 1)*i))
Value of character type 2 on class type
1 (q) * exp(2π𝑖(6//(q - 1)*i))
1: (q) * exp(2π𝑖(6//(q - 1)*i))
Value of character type 3 on class type
1 (q + 1) * exp(2π𝑖(1//(q - 1)*i*l + 3//(q - 1)*i))
1: (q + 1) * exp(2π𝑖(1//(q - 1)*i*l + 3//(q - 1)*i))
Value of character type 4 on class type
1 (q - 1) * exp(2π𝑖(3//(q - 1)*i))
1: (q - 1) * exp(2π𝑖(3//(q - 1)*i))
```
"""
function specclassparam!(t::CharTable{T}, class::Int64, var::FracPoly{T}, expr::RingElement) where T <: NfPoly
Expand Down
20 changes: 8 additions & 12 deletions src/Ortho.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ Return the (generic) class multiplication constant of the class types `class1`,
# Examples
```jldoctest
julia> g=genchartab(\"SL2.0\");
julia> g=genchartab("SL2.0");
julia> classmult(g,2,2,4)
(q + 1, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[1//(q + 1)*a3 ∈ ℤ]))
(q + 1, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[(a3)//(q + 1) ∈ ℤ]))
```
"""
function classmult(t::CharTable{T}, class1::Int64, class2::Int64, class3::Int64) where T <: NfPoly
Expand Down Expand Up @@ -91,11 +90,10 @@ Return the scalar product between the character types `char1` and `char2`.
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");
julia> scalar(g,3,2)
(0, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[1//(q - 1)*l1 + 1//(q - 1)*k1 - 2//(q - 1)*k2 ∈ ℤ, 1//(q - 1)*l1 - 1//(q - 1)*k2 ∈ ℤ, 1//(q - 1)*k1 - 1//(q - 1)*k2 ∈ ℤ]))
(0, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[(l1 + k1 - 2*k2)//(q - 1) ∈ ℤ, (l1 - k2)//(q - 1) ∈ ℤ, (k1 - k2)//(q - 1) ∈ ℤ]))
```
"""
function scalar(t::CharTable{T}, char1::Int64, char2::Int64) where T <: NfPoly
Expand Down Expand Up @@ -142,11 +140,10 @@ Return the (generic) norm of the class type `class`.
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");
julia> ortho2norm(g,2)
(1, Set{GenericCharacterTables.ParameterException{QQPolyRingElem}}())
```
"""
function ortho2norm(t::CharTable{T}, class::Int64) where T <: NfPoly
Expand Down Expand Up @@ -182,11 +179,10 @@ Return the (generic) scalar product between the class types `class1` and `class2
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> ortho2scalar(g,3,2)
(0, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[1//(q - 1)*i1 + 1//(q - 1)*j1 - 2//(q - 1)*i2 ∈ ℤ, 1//(q - 1)*i1 - 1//(q - 1)*i2 ∈ ℤ, 1//(q - 1)*j1 - 1//(q - 1)*i2 ∈ ℤ]))
julia> g=genchartab("GL2");
julia> ortho2scalar(g,3,2)
(0, Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[(i1 + j1 - 2*i2)//(q - 1) ∈ ℤ, (i1 - i2)//(q - 1) ∈ ℤ, (j1 - i2)//(q - 1) ∈ ℤ]))
```
"""
function ortho2scalar(t::CharTable{T}, class1::Int64, class2::Int64) where T <: NfPoly
Expand Down
18 changes: 16 additions & 2 deletions src/Parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ struct ParameterException{T}
end
end
end
Base.show(io::IO, a::ParameterException) = print(io, "$(a.expression) ∈ ℤ")
function Base.show(io::IO, a::ParameterException)
# merge multiple denominators from coefficients into one for nicer printing
d = lcm(map(denominator,Oscar.coefficients(a.expression)))
if is_one(d)
print(io, "$(a.expression) ∈ ℤ")

Check warning on line 55 in src/Parameter.jl

View check run for this annotation

Codecov / codecov/patch

src/Parameter.jl#L55

Added line #L55 was not covered by tests
else
print(io, "($(a.expression*d))//($d) ∈ ℤ")
end
end
function Base.show(io::IO, m::MIME{Symbol("text/latex")}, a::ParameterException)
print(io, "$(repr("text/latex",a.expression)) \\in \\mathbb{Z}")
# merge multiple denominators from coefficients into one for nicer printing
d = lcm(map(denominator,Oscar.coefficients(a.expression)))
if is_one(d)
print(io, repr("text/latex",a.expression), " \\in \\mathbb{Z}")

Check warning on line 64 in src/Parameter.jl

View check run for this annotation

Codecov / codecov/patch

src/Parameter.jl#L62-L64

Added lines #L62 - L64 were not covered by tests
else
print(io, "\\frac{", repr("text/latex",a.expression*d), "}{", d, "} \\in \\mathbb{Z}")

Check warning on line 66 in src/Parameter.jl

View check run for this annotation

Codecov / codecov/patch

src/Parameter.jl#L66

Added line #L66 was not covered by tests
end
end
Base.:(==)(x::ParameterException, y::ParameterException) = x.expression == y.expression # needed for Set to work
Base.hash(x::ParameterException, h::UInt) = hash(x.expression, h) # needed for Set to work
Expand Down
64 changes: 41 additions & 23 deletions src/Show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export order
export param
# TODO PrintValPhi, PrintToTex?

import Oscar: pretty, Indent
import Oscar: pretty, Indent, Dedent

function Base.show(io::IO, t::Table)
io = pretty(io)
Expand Down Expand Up @@ -228,14 +228,13 @@ This includes the parameter names, ranges and exceptions. Leaving `char` unspeci
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");

Check warning on line 231 in src/Show.jl

View check run for this annotation

Codecov / codecov/patch

src/Show.jl#L231

Added line #L231 was not covered by tests
julia> printcharparam(g)
1 k ∈ {1,…, q - 1}
2 k ∈ {1,…, q - 1}
3 k ∈ {1,…, q - 1}, l ∈ {1,…, q - 1} except 1//(q - 1)*l - 1//(q - 1)*k ∈ ℤ
4 k ∈ {1,…, q^2 - 1} except 1//(q + 1)*k ∈ ℤ
3 k ∈ {1,…, q - 1}, l ∈ {1,…, q - 1} except (l - k)//(q - 1) ∈ ℤ
4 k ∈ {1,…, q^2 - 1} except (k)//(q + 1) ∈ ℤ
```
"""
function printcharparam(t::CharTable, char::Union{Int64, Nothing}=nothing)
Expand All @@ -261,14 +260,13 @@ This includes the parameter names, ranges and exceptions. Leaving `class` unspec
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");

Check warning on line 263 in src/Show.jl

View check run for this annotation

Codecov / codecov/patch

src/Show.jl#L263

Added line #L263 was not covered by tests
julia> printclassparam(g)
1 i ∈ {1,…, q - 1}
2 i ∈ {1,…, q - 1}
3 i ∈ {1,…, q - 1}, j ∈ {1,…, q - 1} except 1//(q - 1)*i - 1//(q - 1)*j ∈ ℤ
4 i ∈ {1,…, q^2 - 1} except 1//(q + 1)*i ∈ ℤ
3 i ∈ {1,…, q - 1}, j ∈ {1,…, q - 1} except (i - j)//(q - 1) ∈ ℤ
4 i ∈ {1,…, q^2 - 1} except (i)//(q + 1) ∈ ℤ
```
"""
function printclassparam(t::CharTable, class::Union{Int64, Nothing}=nothing)
Expand Down Expand Up @@ -361,26 +359,21 @@ Leaving both unspecified will print all values of t
# Examples
```jldoctest
julia> g=genchartab(\"GL2\");
julia> g=genchartab("GL2");
julia> printval(g,char=1)
Value of character type 1 on class type
1 (1) * exp(2π𝑖(2//(q - 1)*i*k))
2 (1) * exp(2π𝑖(2//(q - 1)*i*k))
3 (1) * exp(2π𝑖(1//(q - 1)*i*k + 1//(q - 1)*j*k))
4 (1) * exp(2π𝑖(1//(q - 1)*i*k))
1: (1) * exp(2π𝑖(2//(q - 1)*i*k))
2: (1) * exp(2π𝑖(2//(q - 1)*i*k))
3: (1) * exp(2π𝑖(1//(q - 1)*i*k + 1//(q - 1)*j*k))
4: (1) * exp(2π𝑖(1//(q - 1)*i*k))
julia> printval(g,char=4,class=2)
Value of character type 4 on class type
2 (-1) * exp(2π𝑖(1//(q - 1)*i*k))
2: (-1) * exp(2π𝑖(1//(q - 1)*i*k))
```
"""
function printval(t::Table; char::Union{Int64, Nothing}=nothing, class::Union{Int64, Nothing}=nothing)
function printval(io::IO, t::Table; char::Union{Int64, Nothing}=nothing, class::Union{Int64, Nothing}=nothing)
if char === nothing
chars=range(1, chartypes(t))
else
Expand All @@ -397,14 +390,39 @@ function printval(t::Table; char::Union{Int64, Nothing}=nothing, class::Union{In
end
classes=[class]
end
io = pretty(io)
for i in chars
println("\nValue of character type $i on class type\n")
println(io, "Value of character type $i on class type", Indent())
for j in classes
println(j, "\t", t.table[i,j])
println(io, j, ": ", t.table[i,j])

Check warning on line 397 in src/Show.jl

View check run for this annotation

Codecov / codecov/patch

src/Show.jl#L397

Added line #L397 was not covered by tests
end
print(io, Dedent())
end
end

printval(t::Table; kwarg...) = printval(stdout, t; kwarg...)

# TODO: document this (and/or replace it by something better)

Check warning on line 405 in src/Show.jl

View check run for this annotation

Codecov / codecov/patch

src/Show.jl#L405

Added line #L405 was not covered by tests
function print_decomposition(io::IO, t::CharTable, char::Int)
io = pretty(io)
print(io, "Decomposing character $char:", Indent())
for i in 1:irrchartypes(t)
println(io)
s, e = scalar(t, i, char)
print(io, "<$i,$char> = $s ")
if !isempty(e)
print(io, "with possible exceptions:", Indent())
for ex in e
print(io, "\n", ex)
end
print(io, Dedent())
end
end
end

print_decomposition(t::CharTable, char::Int) = print_decomposition(stdout, t, char)
export print_decomposition

Check warning on line 425 in src/Show.jl

View check run for this annotation

Codecov / codecov/patch

src/Show.jl#L422-L425

Added lines #L422 - L425 were not covered by tests
"""
nrparams(t::CharTable)
Expand Down
7 changes: 3 additions & 4 deletions src/SumProc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,19 @@ Return the sum of `a`, from `var=lower` to `upper` as `CycloFrac{T}`.
The second return value is a set of exceptions where the result may be false.
# Examples
```jldoctest
julia> R, q = polynomial_ring(QQ, \"q\");
julia> R, q = polynomial_ring(QQ, "q");
julia> Q=fraction_field(R);
julia> S=UniversalPolynomialRing(Q);
julia> i, = gens(S, [\"i\"]);
julia> i, = gens(S, ["i"]);
julia> a = e2p(1//(q-1)*i)
(1) * exp(2π𝑖(1//(q - 1)*i))
julia> nesum(a, i, 1, q-1)
((0) // (1), Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[1//(q - 1) ∈ ℤ]))
((0) // (1), Set(GenericCharacterTables.ParameterException{QQPolyRingElem}[(1)//(q - 1) ∈ ℤ]))
```
"""
function nesum(a::CycloFrac{T}, var::Int64, lower::Int64, upper::Union{Int64,T}, congruence::Union{Tuple{T,T},Nothing}=nothing) where T <: NfPoly
Expand Down

0 comments on commit 121270d

Please sign in to comment.