Skip to content

Commit

Permalink
improve type stability
Browse files Browse the repository at this point in the history
  • Loading branch information
SoongNoonien committed Sep 17, 2024
1 parent 1b223f5 commit 2ccf4cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/CharTable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function CharTable(order::UPoly, table::Matrix{GenericCyclo}, classinfo::Vector{
end

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

classsum(t::CharTable, class::Integer, x::Union{GenericCyclo, GenericCycloFrac}) = t.classsums[class](x)::Union{GenericCyclo, GenericCycloFrac}

@doc raw"""
GenericCharacter <: AbstractGenericCharacter
Expand Down Expand Up @@ -86,6 +88,8 @@ struct GenericCharacter <: AbstractGenericCharacter
params::Parameters # Info about the parameters in this character type
end

charsum(c::GenericCharacter, x::Union{GenericCyclo, GenericCycloFrac}) = c.sum(x)::Union{GenericCyclo, GenericCycloFrac}

@doc raw"""
(t::CharTable)(c::GenericCharacter)
Expand Down Expand Up @@ -143,7 +147,7 @@ struct SimpleCharTable{T} <: Table
end

Base.getindex(ct::SimpleCharTable{T}, i::Integer) where T<:NfPoly = ct.chars[i]::SimpleGenericCharacter{T}
Base.getindex(ct::SimpleCharTable{T}, i::Integer, j::Integer) where T<:NfPoly = ct.chars[i].values[j]::T
Base.getindex(ct::SimpleCharTable{T}, i::Integer, j::Integer) where T<:NfPoly = ct[i].values[j]::T
Base.setindex!(ct::SimpleCharTable{T}, v::T, i::Integer, j::Integer) where T<:NfPoly = setindex!(ct.chars[i].values, v, j)

@doc raw"""
Expand Down
10 changes: 5 additions & 5 deletions src/Ortho.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function classmult(t::CharTable, class1::Int64, class2::Int64, class3::Int64)
val1=shift_class_parameters(t, t[char, class1], 1)
val2=shift_class_parameters(t, t[char, class2], 2)
val3=shift_class_parameters(t, t[char, class3], 3)
sum+=t.order*t[char].sum(val1*val2*conj(val3))//t[char].degree # TODO move t.order* to the end of the function
sum+=t.order*charsum(t[char], val1*val2*conj(val3))//t[char].degree # TODO move t.order* to the end of the function
end
return shrink((t.classlength[class1]*t.classlength[class2])*sum//(t.order^2))
end
Expand Down Expand Up @@ -72,7 +72,7 @@ function Oscar.norm(char::GenericCharacter)
sum=0
for class in 1:classtypes(t)
val=char[class]
sum+=t.classlength[class]*t.classsums[class](val*conj(val))
sum+=t.classlength[class]*classsum(t, class, val*conj(val))
end
return shrink(sum//t.order)
end
Expand Down Expand Up @@ -125,7 +125,7 @@ function Oscar.scalar_product(char1::GenericCharacter, char2::GenericCharacter)
for class in 1:classtypes(t)
val1=shift_char_parameters(t, char1[class], 1)
val2=shift_char_parameters(t, char2[class], 2)
sum+=t.classlength[class]*t.classsums[class](val1*conj(val2))
sum+=t.classlength[class]*classsum(t, class, val1*conj(val2))
end
return shrink(sum//t.order)
end
Expand Down Expand Up @@ -175,7 +175,7 @@ function ortho2norm(t::CharTable, class::Int64)
sum=0
for char in 1:irrchartypes(t)
val=t[char, class]
sum+=t[char].sum(val*conj(val))
sum+=charsum(t[char], val*conj(val))
end
return shrink(t.classlength[class]*sum//t.order)
end
Expand Down Expand Up @@ -229,7 +229,7 @@ function ortho2scalar(t::CharTable, class1::Int64, class2::Int64)
for char in 1:irrchartypes(t)
val1=shift_class_parameters(t, t[char, class1], 1)
val2=shift_class_parameters(t, t[char, class2], 2)
sum+=t[char].sum(val1*conj(val2))
sum+=charsum(t[char], val1*conj(val2))
end
return shrink(t.classlength[class1]*sum//t.order)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ julia> classtypes(g)
```
"""
function classtypes(t::Table) # TODO ?
length(t.chars[1].values)
length(t[1].values)
end

@doc raw"""
Expand Down

0 comments on commit 2ccf4cb

Please sign in to comment.