Skip to content

Commit

Permalink
Merge pull request #148 from ThomasBreuer/TB_show_complex_conj_via_ov…
Browse files Browse the repository at this point in the history
…erline

show the complex conjugate value via overline
  • Loading branch information
fieker committed Sep 3, 2020
2 parents a273bd0 + 6f2ea25 commit fdab4e6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
48 changes: 32 additions & 16 deletions examples/GroupCharacters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ show(t) # call `labelled_matrix_formatted`
GAP.Globals.Display( t.GAPTable ) # compare with GAP's Display
show(stdout, MIME("text/html"), t) # produce LaTeX output
# show a legend of irrationalities instead of self-explanatory values
# show a legend of irrationalities instead of self-explanatory values,
# in the screen format ...
show(IOContext(stdout, :with_legend => true), t)
# ... and in LaTeX format
show(IOContext(stdout, :with_legend => true), MIME("text/html"), t)
# show the screen format for a table with real and non-real irrationalities
show(IOContext(stdout, :with_legend => true),
Main.GroupCharacters.character_table("L2(11)"))
# show some separating lines, in the screen format ...
show(IOContext(stdout, :column_separators => [0,5],
:row_separators => [0,5]), t)
Expand Down Expand Up @@ -172,6 +180,8 @@ function gap_cyclotomic(elm::QabModule.QabElem)
return GAP.Globals.CycList(GAP.julia_to_gap(coeffs))
end

complex_conjugate(elm::QabModule.QabElem) = elm^QabModule.QabAutomorphism(-1)


#############################################################################
##
Expand Down Expand Up @@ -218,21 +228,18 @@ function character_table(G::Oscar.GAPGroup, p::Int = 0)
end

function character_table(id::String, p::Int = 0)
if GAP.Globals.IsBoundGlobal(GAP.julia_to_gap("CTblLib"))
tbl = GAP.Globals.CharacterTable(GAP.julia_to_gap(id))
hasproperty(GAP.Globals, :CTblLib) || error("no character table library available")
tbl = GAP.Globals.CharacterTable(GAP.julia_to_gap(id))
if tbl == GAP.Globals.fail
return nothing
elseif p != 0
isprime(p) || error("p must be 0 or a prime integer")
tbl = GAP.Globals.mod(tbl, GAP.julia_to_gap(p))
if tbl == GAP.Globals.fail
return nothing
elseif p != 0
isprime(p) || error("p must be 0 or a prime integer")
tbl = GAP.Globals.mod(tbl, GAP.julia_to_gap(p))
if tbl == GAP.Globals.fail
return nothing
end
end
return GAPGroupCharacterTable(tbl, p)
else
error("no character table library available")
end
return GAPGroupCharacterTable(tbl, p)
end


Expand Down Expand Up @@ -299,6 +306,10 @@ function matrix_of_strings(tbl::GAPGroupCharacterTable; alphabet::String = "")
else
name, state = iterate(iter, state)
push!(legend, val => name)
valbar = complex_conjugate(val)
if valbar != val
push!(legend, valbar => "\\overline{"*name*"}")
end
m[i,j] = name
end
end
Expand Down Expand Up @@ -487,16 +498,19 @@ function group_class_function(tbl::GAPGroupCharacterTable, values::Vector{QabMod
return GAPGroupClassFunction(tbl, GAP.Globals.ClassFunction(tbl.GAPTable, GAP.julia_to_gap([gap_cyclotomic(x) for x in values])))
end

#function group_class_function(G::Oscar.GAPGroup, values::Vector{QabModule.QabElem})
#end
function group_class_function(G::Oscar.GAPGroup, values::Vector{QabModule.QabElem})
return group_class_function(character_table(G), values)
end

function trivial_character(tbl::GAPGroupCharacterTable)
val = QabModule.QabElem(1)
return group_class_function(tbl, [val for i in 1:ncols(tbl)])
end

#function trivial_character(G::Oscar.GAPGroup)
#end
function trivial_character(G::Oscar.GAPGroup)
val = QabModule.QabElem(1)
return group_class_function(G, [val for i in 1:GAP.Globals.NrConjugacyClasses(G.X)])
end

Base.length(chi::GAPGroupClassFunction) = length(chi.values)

Expand Down Expand Up @@ -556,3 +570,5 @@ function Base.:^(chi::GAPGroupClassFunction, n::Int)
end

end # module

using .GroupCharacters
14 changes: 10 additions & 4 deletions examples/MatrixDisplay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
#T TODO:
#T - Support left/centered/right alignment of columns and of the whole table.
#T - Concerning irrational values in character tables:
#T in `matrix_of_strings`, identify also complex conjugates (mark with
#T overline) and unique Galois conjugates (mark with superscript *);
#T in `matrix_of_strings`,
#T identify also unique Galois conjugates (mark with superscript *);
#T show both values in the footer.
#T (For elements in quadratic fields, show also an expression in terms of
#T square roots.)


# `lpad` is wrong for example for strings containing overlined characters,
# such as "A̅".
# (This had been observed already by Jean Michel.)
mylpad(s::String,n::Int) = " "^(n-textwidth(s))*s

# for conversions from \LaTeX format to unicode format,
# deals with subscripts and superscripts in braces `{}`,
# character values, character names
Expand All @@ -37,6 +42,7 @@ function replace_TeX(str::String)
str = replace(str, "\\zeta" => "ζ")
str = replace(str, r"\^\{[-0123456789]*\}" => (s -> map(x->sup[x], s[3:end-1])))
str = replace(str, r"_\{[-0123456789]*\}" => (s -> map(x->sub[x], s[3:end-1])))
str = replace(str, r"\\overline\{(?<nam>[A-Z]*)\}" => s"\g<nam>\u0305")
return str
end

Expand Down Expand Up @@ -261,9 +267,9 @@ function labelled_matrix_formatted(io::IO, mat::Matrix{String})
println(io, "\\hline")
end
else
println(io, join(map(lpad, leftpart[i,:], widths_leftpart), " "),
println(io, join(map(mylpad, leftpart[i,:], widths_leftpart), " "),
cprefix,
join(join.(collect(zip(map(lpad, rightpart[i,:][crange], widths_rightpart[crange]), cpattern)))))
join(join.(collect(zip(map(mylpad, rightpart[i,:][crange], widths_rightpart[crange]), cpattern)))))
if i in row_separators
println(io, hline)
end
Expand Down

0 comments on commit fdab4e6

Please sign in to comment.