Skip to content

Commit

Permalink
Add a Types.jl to define all types
Browse files Browse the repository at this point in the history
  • Loading branch information
SoongNoonien committed Nov 29, 2024
1 parent fc31545 commit dcc000a
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 283 deletions.
167 changes: 0 additions & 167 deletions src/CharTable.jl
Original file line number Diff line number Diff line change
@@ -1,66 +1,3 @@
abstract type Table end
abstract type AbstractGenericCharacter end

# T is usually of the type NfPoly.
# `argumentring` is expected to have 6 complete batches of variables.
# These are used to shift the variables to calculate e.g. scalar products.
# `linkomb!` may add variables to `argumentring` to shift the variables even further.
# Therefore it is needed to disable caching in `argumentring`
# to fix possible interplay issues caused by using multiple tables.
# See for example A1/GL2.jl
@doc raw"""
CharTable <: Table
The type for generic character tables. This is used to model generic character tables containing generic cyclotomic entries.
# Examples
```jldoctest
julia> g=generic_character_table("GL2")
Generic character table GL2
of order q^4 - q^3 - q^2 + q
with 4 irreducible character types
with 4 class types
with parameters (i, j, l, k)
```
"""
struct CharTable <: Table
order::UPoly # Order of the associated group
classinfo::Vector{<:Any} # Info about class types
classlength::Vector{UPoly} # Order of the classes in each type
classsums::Vector{Function} # Functions to sum a cyclotomic over all classes in a type
classparamindex::Vector{Int64} # Indices of the class parameters
charparamindex::Vector{Int64} # Indices of the character parameters
classparams::Vector{Parameters} # Info about the parameters of each class type
ring::GenericCycloRing # Parent ring of the cyclotomics in this table
information::String # General info about the table
chars::Vector{<:AbstractGenericCharacter}
importname::String # This name can be used to import the table, a "*" indicates a modified table
end
function CharTable(order::UPoly, table::Matrix{GenericCyclo}, classinfo::Vector{<:Any},
classlength::Vector{UPoly},
charinfo::Vector{<:Any}, chardegree::Vector{UPoly}, classsums::Vector{Function},
charsums::Vector{Function},
classparamindex::Vector{Int64}, charparamindex::Vector{Int64},
classparams::Vector{Parameters}, charparams::Vector{Parameters},
ring::GenericCycloRing, information::String, importname::String)
num_chars = size(table, 1)
chars = Vector{GenericCharacter}(undef, num_chars)
ct = CharTable(order, classinfo, classlength, classsums, classparamindex, charparamindex,
classparams, ring, information, chars, importname)
for i in 1:num_chars
ct.chars[i] = GenericCharacter(
ct,
table[i, :],
charinfo[i],
chardegree[i],
charsums[i],
charparams[i],
ParameterSubstitution[],
)
end
return ct
end

getindex(ct::CharTable, i::Integer) = ct.chars[i]::GenericCharacter
getindex(ct::CharTable, i::Integer, j::Integer) = ct[i].values[j]::GenericCyclo

Expand All @@ -69,37 +6,6 @@ eltype(::Type{CharTable}) = GenericCharacter
classsum(t::CharTable, class::Integer, x::Union{GenericCyclo,GenericCycloFrac}) =
t.classsums[class](x)::Union{GenericCyclo,GenericCycloFrac}

@doc raw"""
GenericCharacter <: AbstractGenericCharacter
The type for generic characters. These are the generic characters used in `CharTable`.
# Examples
```jldoctest
julia> g=generic_character_table("GL2");
julia> g[1]
Generic character of GL2
with parameters
k ∈ {1,…, q - 1}
of degree 1
with values
exp(2π𝑖((2*i*k)//(q - 1)))
exp(2π𝑖((2*i*k)//(q - 1)))
exp(2π𝑖((i*k + j*k)//(q - 1)))
exp(2π𝑖((i*k)//(q - 1)))
```
"""
struct GenericCharacter <: AbstractGenericCharacter
parent::CharTable
values::Vector{GenericCyclo}
info::Any
degree::UPoly # Degree of the characters in this type
sum::Union{Function,Nothing} # Function to sum a Cyclotomic over all characters in this type
params::Parameters # Info about the parameters in this character type
substitutions::Vector{ParameterSubstitution}
end

eltype(::Type{GenericCharacter}) = GenericCyclo

charsum(c::GenericCharacter, x::Union{GenericCyclo,GenericCycloFrac}) =
Expand All @@ -122,48 +28,6 @@ function (t::CharTable)(c::GenericCharacter)
)
end

# T is usually of th type NfPoly.
@doc raw"""
SimpleCharTable{T} <: Table
The type for simple generic character tables. This is used to model generic character tables containing polynomial entries. The type parameter `T` is
the type of the table entries.
# Examples
```jldoctest
julia> g=generic_character_table("uniGL2")
Generic character table uniGL2
of order q^4 - q^3 - q^2 + q
with 2 irreducible character types
with 4 class types
without parameters
```
"""
struct SimpleCharTable{T} <: Table
order::T # Order of the associated group
classinfo::Vector{<:Any} # Info about class types
classlength::Vector{T} # Order of the classes in each type
classtypeorder::Vector{T} # Number of classes in each type
ring::PolyRing # Ring of polynomials of type T used in table
information::String # General info about the table
chars::Vector{<:AbstractGenericCharacter}
importname::String # This name can be used to import the table
function SimpleCharTable(order::T, table::Matrix{T}, classinfo::Vector{<:Any},
classlength::Vector{T},
classtypeorder::Vector{T}, charinfo::Vector{<:Any}, chardegree::Vector{T},
ring::PolyRing, information::String, importname::String) where {T<:NfPoly}
num_chars = size(table, 1)
chars = Vector{SimpleGenericCharacter{T}}(undef, num_chars)
ct = new{T}(
order, classinfo, classlength, classtypeorder, ring, information, chars, importname
)
for i in 1:num_chars
ct.chars[i] = SimpleGenericCharacter(ct, table[i, :], charinfo[i], chardegree[i])
end
return ct
end
end

getindex(ct::SimpleCharTable{T}, i::Integer) where {T<:NfPoly} =
ct.chars[i]::SimpleGenericCharacter{T}
getindex(ct::SimpleCharTable{T}, i::Integer, j::Integer) where {T<:NfPoly} =
Expand All @@ -174,37 +38,6 @@ eltype(::Type{SimpleCharTable{T}}) where {T<:NfPoly} = SimpleGenericCharacter{T}
length(ct::Table) = length(ct.chars)
iterate(ct::Table, state::Integer=1) = state > length(ct) ? nothing : (ct[state], state + 1)

@doc raw"""
SimpleGenericCharacter <: AbstractGenericCharacter
The type for simple generic characters. These are the generic characters used in `SimpleCharTable`.
# Examples
```jldoctest
julia> g=generic_character_table("uniGL2")
Generic character table uniGL2
of order q^4 - q^3 - q^2 + q
with 2 irreducible character types
with 4 class types
without parameters
julia> g[1]
Generic character of uniGL2
of degree q
with values
q
0
1
-1
```
"""
struct SimpleGenericCharacter{T} <: AbstractGenericCharacter
parent::SimpleCharTable{T}
values::Vector{T}
info::Any
degree::T # Degree of the characters in this type
end

parent(c::AbstractGenericCharacter) = c.parent
getindex(c::AbstractGenericCharacter, i::Integer) = c.values[i]

Expand Down
1 change: 1 addition & 0 deletions src/GenericCharacterTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const NfPoly = Union{PolyRingElem{QQFieldElem},PolyRingElem{AbsSimpleNumFieldEle

include("Imports.jl")
include("GenericCyclotomics.jl")
include("Types.jl")
include("ParameterExceptions.jl")
include("GenericCyclotomicFractions.jl")
include("Parameter.jl")
Expand Down
24 changes: 0 additions & 24 deletions src/GenericConjugacyClasses.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
abstract type AbstractGenericConjugacyClass end

@doc raw"""
GenericConjugacyClass <: AbstractGenericConjugacyClass
The type for generic conjugacy classes. These are the generic conjugacy classes used in `CharTable`.
"""
struct GenericConjugacyClass <: AbstractGenericConjugacyClass
parent::CharTable
index::Int64
values::Union{Vector{GenericCyclo},Nothing}
substitutions::Vector{ParameterSubstitution}
end

@doc raw"""
conjugacy_class_type(t::CharTable, class::Int64)
Expand All @@ -25,16 +11,6 @@ getindex(c::GenericConjugacyClass, i::Integer) =

eltype(::Type{GenericConjugacyClass}) = GenericCyclo

@doc raw"""
SimpleGenericConjugacyClass <: AbstractGenericConjugacyClass
The type for simple generic conjugacy classes. These are the generic conjugacy classes used in `SimpleCharTable`.
"""
struct SimpleGenericConjugacyClass{T} <: AbstractGenericConjugacyClass
parent::SimpleCharTable{T}
index::Int64
end

@doc raw"""
conjugacy_class_type(t::SimpleCharTable{T}, class::Int64) where T <: NfPoly
Expand Down
51 changes: 0 additions & 51 deletions src/GenericCyclotomicFractions.jl
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
# This models fractions of sums of cyclotomics.
# The simplification is currently only very basic.
# According to the original implementation
# more advanced simplifications seem to have
# no positive effect on the performance.
@doc raw"""
GenericCycloFrac
The type for fractions of generic cyclotomic numbers.
# Examples
```jldoctest
julia> R = universal_polynomial_ring(QQ; cached=false);
julia> q = gen(R, "q");
julia> S = generic_cyclotomic_ring(R);
julia> a = S(q; exponent=1//(q-1))
q*exp(2π𝑖(1//(q - 1)))
julia> b = S(q^2; exponent=1//(q^2-1))
q^2*exp(2π𝑖(1//(q^2 - 1)))
julia> a//b
q*exp(2π𝑖(1//(q - 1)))//(q^2*exp(2π𝑖(1//(q^2 - 1))))
```
"""
struct GenericCycloFrac
numerator::GenericCyclo
denominator::GenericCyclo
exceptions::ParameterExceptions # The element may only be evaluated if none of the exceptions evaluates to an integer.
function GenericCycloFrac(
numerator::GenericCyclo,
denominator::GenericCyclo,
exceptions::ParameterExceptions;
simplify::Bool=true,
)
check_parent(numerator, denominator)
if simplify
if iszero(numerator)
return new(numerator, one(denominator), exceptions)
elseif numerator == denominator
o = one(denominator)
return new(o, o, exceptions)
end
end
return new(numerator, denominator, exceptions)
end
end

function add_exception!(a::GenericCycloFrac, exception::UPolyFrac)
add_exception!(a.exceptions, exception)
end
Expand Down
28 changes: 0 additions & 28 deletions src/Parameter.jl
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
@doc raw"""
Parameter
A paramter of a generic character or class type unique up to a polynomial modulus. They are used in `Parameters`.
"""
struct Parameter
var::UPoly # Actual name of the parameter # TODO make this an Int?
modulus::UPoly # Said modulus
end
show(io::IO, a::Parameter) = print(io, "$(a.var) ∈ {1,…, $(a.modulus)}")

@doc raw"""
ParameterSubstitution
A substitution of paramters used in `Parameters`. They are generated by for example `specclassparam!`.
"""
struct ParameterSubstitution
var::UPoly # The name of the replaced parameter # TODO make this an Int?
expression::UPoly # The substitute for the parameter # TODO do we need UPolyFrac here?
end
show(io::IO, a::ParameterSubstitution) = print(io, "$(a.var) = $(a.expression)")

@doc raw"""
Parameters
Parameters of generic characters and class types. This is used in `GenericCharacter` and `CharTable` and is only of internal use.
"""
struct Parameters
params::Vector{Parameter}
exceptions::Vector{UPolyFrac}
end

getindex(p::Parameters, i::Integer) = p.params[i]

eltype(::Type{Parameters}) = Parameter
Expand Down
13 changes: 0 additions & 13 deletions src/ParameterExceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ function is_integer(x::UPolyFrac)
return false
end

@doc raw"""
ParameterExceptions
A collection of parameter exceptions used in `GenericCycloFrac`.
"""
struct ParameterExceptions
exceptions::Vector{UPolyFrac}
end

function parameter_exceptions()
ParameterExceptions(UPolyFrac[])
end

@doc raw"""
add_exception!(a::ParameterExceptions, exception::UPolyFrac)
Expand Down
Loading

0 comments on commit dcc000a

Please sign in to comment.