From dcc000a76ca9d1f5997299c07f8d4d884a8aac7b Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Fri, 29 Nov 2024 01:26:07 +0100 Subject: [PATCH] Add a `Types.jl` to define all types --- src/CharTable.jl | 167 ----------------- src/GenericCharacterTables.jl | 1 + src/GenericConjugacyClasses.jl | 24 --- src/GenericCyclotomicFractions.jl | 51 ------ src/Parameter.jl | 28 --- src/ParameterExceptions.jl | 13 -- src/Types.jl | 285 ++++++++++++++++++++++++++++++ 7 files changed, 286 insertions(+), 283 deletions(-) create mode 100644 src/Types.jl diff --git a/src/CharTable.jl b/src/CharTable.jl index 48a5586..a3eb273 100644 --- a/src/CharTable.jl +++ b/src/CharTable.jl @@ -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 @@ -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}) = @@ -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} = @@ -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] diff --git a/src/GenericCharacterTables.jl b/src/GenericCharacterTables.jl index a78a52a..e68702f 100644 --- a/src/GenericCharacterTables.jl +++ b/src/GenericCharacterTables.jl @@ -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") diff --git a/src/GenericConjugacyClasses.jl b/src/GenericConjugacyClasses.jl index 1da1979..f71bcea 100644 --- a/src/GenericConjugacyClasses.jl +++ b/src/GenericConjugacyClasses.jl @@ -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) @@ -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 diff --git a/src/GenericCyclotomicFractions.jl b/src/GenericCyclotomicFractions.jl index b535329..9da5d51 100644 --- a/src/GenericCyclotomicFractions.jl +++ b/src/GenericCyclotomicFractions.jl @@ -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 diff --git a/src/Parameter.jl b/src/Parameter.jl index cdb2df0..27a9e66 100644 --- a/src/Parameter.jl +++ b/src/Parameter.jl @@ -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 diff --git a/src/ParameterExceptions.jl b/src/ParameterExceptions.jl index e1d86b6..b1fe6b9 100644 --- a/src/ParameterExceptions.jl +++ b/src/ParameterExceptions.jl @@ -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) diff --git a/src/Types.jl b/src/Types.jl new file mode 100644 index 0000000..935bd9f --- /dev/null +++ b/src/Types.jl @@ -0,0 +1,285 @@ +@doc raw""" + ParameterExceptions + +A collection of parameter exceptions used in `GenericCycloFrac`. +""" +struct ParameterExceptions + exceptions::Vector{UPolyFrac} +end + +function parameter_exceptions() + ParameterExceptions(UPolyFrac[]) +end + +# 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 + +@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 + +@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 + +@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 + +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 + +@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 + +# 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 + +@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 + +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""" + 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 +