Skip to content

Commit

Permalink
increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SoongNoonien committed Aug 17, 2024
1 parent 3184705 commit 33b5b48
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 9 deletions.
60 changes: 57 additions & 3 deletions src/ModifyTable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export tensor_product, tensor!, omega, omega!, lincomb, lincomb!, specialize, sp
# TODO deal with ParameterSubstitution, this is not done in the original implementation.

@doc raw"""
tensor_product(char1::T, char2::T) where T <: AbstractGenericCharacter
tensor_product(char1::GenericCharacter{T}, char2::GenericCharacter{T}) where T<:PolyRingElem
Return the tensor product of the character types `char1` and `char2`.
This can also be obtained via `char1 * char2`.
Expand Down Expand Up @@ -51,6 +51,25 @@ function tensor_product(char1::GenericCharacter{T}, char2::GenericCharacter{T})
return GenericCharacter{T}(t, new_char_values, ["Tensor of type $char1id and $char2id"], new_char_degree, nothing, new_char_params)
end

@doc raw"""
tensor_product(char1::SimpleGenericCharacter{T}, char2::SimpleGenericCharacter{T}) where T<:PolyRingElem
Return the tensor product of the character types `char1` and `char2`.
This can also be obtained via `char1 * char2`.
# Examples
```jldoctest
julia> g = greenfuntab("GL3");
julia> tensor_product(g[1],g[2])
Generic character of GL3
of degree -q^6 - 2*q^5 - 2*q^4 + 2*q^2 + 2*q + 1
with values
-q^6 - 2*q^5 - 2*q^4 + 2*q^2 + 2*q + 1
2*q + 1
1
```
"""
function tensor_product(char1::SimpleGenericCharacter{T}, char2::SimpleGenericCharacter{T}) where T<:PolyRingElem
if parent(char1) != parent(char2)
throw(DomainError((parent(char1),parent(char2)), "Tables do not match."))
Expand Down Expand Up @@ -99,7 +118,7 @@ function tensor!(t::Table{T}, char1::Int64, char2::Int64) where T <: NfPoly
end

@doc raw"""
omega(char::T) where T <: AbstractGenericCharacter
omega(char::GenericCharacter{T}) where T <: NfPoly
Return the (generic) central character of the character type `char`.
Expand Down Expand Up @@ -130,6 +149,25 @@ function omega(char::GenericCharacter{T}) where T <: NfPoly
end
return GenericCharacter{T}(t, new_char_values, ["Omega of type $charid"], new_char_degree, nothing, char.params)
end

@doc raw"""
omega(char::SimpleGenericCharacter{T}) where T <: NfPoly
Return the (generic) central character of the character type `char`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> omega(g[1])
Generic character of GL3
of degree 1
with values
1
2*q^2 - q - 1
q^3 - 2*q^2 + q
```
"""
function omega(char::SimpleGenericCharacter{T}) where T <: NfPoly # TODO is correct?
t=parent(char)
charid=chartypeid(char)
Expand Down Expand Up @@ -167,9 +205,25 @@ function omega!(t::Table{T}, char::Int64) where T <: NfPoly
end

@doc raw"""
lincomb(coeffs::Vector{Int64}, chars::Vector{AbstractGenericCharacter{T}}) where T <: NfPoly
lincomb(coeffs::Vector{Int64}, chars::Vector{GenericCharacter{T}}) where T <: NfPoly
Return the linear combination of the character types `chars` with coefficients `coeffs`.
# Examples
```jldoctest
julia> g=genchartab("GL2");
julia> lincomb([5,1],[g[1],g[2]])
Generic character of GL2
with parameters
kl1 ∈ {1,…, q - 1}, kl2 ∈ {1,…, q - 1}
of degree q + 5
with values
q*exp(2π𝑖(2//(q - 1)*i*kl2)) + 5*exp(2π𝑖(2//(q - 1)*i*kl1))
5*exp(2π𝑖(2//(q - 1)*i*kl1))
exp(2π𝑖(1//(q - 1)*i*kl2 + 1//(q - 1)*j*kl2)) + 5*exp(2π𝑖(1//(q - 1)*i*kl1 + 1//(q - 1)*j*kl1))
5*exp(2π𝑖(1//(q - 1)*i*kl1)) + -1*exp(2π𝑖(1//(q - 1)*i*kl2))
```
"""
function lincomb(coeffs::Vector{Int64}, chars::Vector{GenericCharacter{T}}) where T <: NfPoly
if length(coeffs)!=length(chars)
Expand Down
81 changes: 75 additions & 6 deletions src/Ortho.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export norm, scalar_product, scalar, ortho2norm, ortho2scalar, classmult
# TODO Should we really return Set{ParameterException{T}}() in SimpleCharTable methods? This seems a bit weird.

@doc raw"""
classmult(t::Table{T}, class1::Int64, class2::Int64, class3::Int64) where T <: NfPoly
classmult(t::CharTable{T}, class1::Int64, class2::Int64, class3::Int64) where T <: NfPoly
Return the (generic) class multiplication constant of the class types `class1`, `class2` and `class3` of the table `t`.
Expand All @@ -29,6 +29,20 @@ function classmult(t::CharTable{T}, class1::Int64, class2::Int64, class3::Int64)
end
return shrink(simplify((t.classlength[class1]*t.classlength[class2])*sum//(t.order^2), t))
end

@doc raw"""
classmult(t::SimpleCharTable{T}, class1::Int64, class2::Int64, class3::Int64) where T <: NfPoly
Return the (generic) class multiplication constant of the class types `class1`, `class2` and `class3` of the table `t`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> classmult(g,1,2,3)
(q + 3)//(q^5 - 2*q^4 + q^3)
```
"""
function classmult(t::SimpleCharTable{T}, class1::Int64, class2::Int64, class3::Int64) where T <: NfPoly # TODO is correct?
if any((class1, class2, class3).>classtypes(t))
throw(DomainError((class1,class2,class3), "Some class types are out of range."))
Expand All @@ -42,7 +56,7 @@ function classmult(t::SimpleCharTable{T}, class1::Int64, class2::Int64, class3::
end

@doc raw"""
norm(char::AbstractGenericCharacter{T}) where T <: NfPoly
norm(char::GenericCharacter{T}) where T <: NfPoly
Return the norm of the character type `char`.
Expand All @@ -63,6 +77,20 @@ function Oscar.norm(char::GenericCharacter{T}) where T <: NfPoly
end
return shrink(simplify(sum//t.order, t))
end

@doc raw"""
norm(char::SimpleGenericCharacter{T}) where T <: NfPoly
Return the norm of the character type `char`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> norm(g[1])
6//(q^3 - 3*q^2 + 3*q - 1)
```
"""
function Oscar.norm(char::SimpleGenericCharacter{T}) where T <: NfPoly
t=parent(char)
sum=0
Expand Down Expand Up @@ -93,7 +121,7 @@ function Oscar.norm(t::Table{T}, char::Int64) where T <: NfPoly
end

@doc raw"""
scalar_product(char1::AbstractGenericCharacter{T}, char2::AbstractGenericCharacter{T}) where T <: NfPoly
scalar_product(char1::GenericCharacter{T}, char2::GenericCharacter{T}) where T <: NfPoly
Return the scalar product between the character types `char1` and `char2`.
Expand Down Expand Up @@ -122,6 +150,20 @@ function Oscar.scalar_product(char1::GenericCharacter{T}, char2::GenericCharacte
end
return shrink(simplify(sum//t.order, t))
end

@doc raw"""
scalar_product(char1::SimpleGenericCharacter{T}, char2::SimpleGenericCharacter{T}) where T <: NfPoly
Return the scalar product between the character types `char1` and `char2`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> scalar_product(g[1],g[2])
0
```
"""
function Oscar.scalar_product(char1::SimpleGenericCharacter{T}, char2::SimpleGenericCharacter{T}) where T <:NfPoly
if parent(char1) != parent(char2)
throw(DomainError((parent(char1),parent(char2)), "Tables do not match."))
Expand Down Expand Up @@ -158,9 +200,8 @@ function Oscar.scalar_product(t::Table{T}, char1::Int64, char2::Int64) where T <
return scalar_product(t[char1], t[char2])
end


@doc raw"""
ortho2norm(t::Table{T}, class::Int64) where T <: NfPoly
ortho2norm(t::CharTable{T}, class::Int64) where T <: NfPoly
Return the (generic) norm of the class type `class`.
Expand All @@ -183,6 +224,20 @@ function ortho2norm(t::CharTable{T}, class::Int64) where T <: NfPoly
end
return shrink(simplify(t.classlength[class]*sum//t.order, t))
end

@doc raw"""
ortho2norm(t::SimpleCharTable{T}, class::Int64) where T <: NfPoly
Return the (generic) norm of the class type `class`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> ortho2norm(g,2)
(5*q^2 + 2*q + 3)//(q^5 - 2*q^4 + q^3)
```
"""
function ortho2norm(t::SimpleCharTable{T}, class::Int64) where T <: NfPoly # TODO is correct?
if class > classtypes(t)
throw(DomainError(class, "Class type is out of range."))
Expand All @@ -195,7 +250,7 @@ function ortho2norm(t::SimpleCharTable{T}, class::Int64) where T <: NfPoly # TO
end

@doc raw"""
ortho2scalar(t::Table{T}, class1::Int64, class2::Int64) where T <: NfPoly
ortho2scalar(t::CharTable{T}, class1::Int64, class2::Int64) where T <: NfPoly
Return the (generic) scalar product between the class types `class1` and `class2`.
Expand Down Expand Up @@ -223,6 +278,20 @@ function ortho2scalar(t::CharTable{T}, class1::Int64, class2::Int64) where T <:
end
return shrink(simplify(t.classlength[class1]*sum//t.order, t))
end

@doc raw"""
ortho2scalar(t::SimpleCharTable{T}, class1::Int64, class2::Int64) where T <: NfPoly
Return the (generic) scalar product between the class types `class1` and `class2`.
# Examples
```jldoctest
julia> g=greenfuntab("GL3");
julia> ortho2scalar(g,2,2)
(5*q^2 + 2*q + 3)//(q^5 - 2*q^4 + q^3)
```
"""
function ortho2scalar(t::SimpleCharTable{T}, class1::Int64, class2::Int64) where T <: NfPoly # TODO is correct?
if any((class1, class2).>classtypes(t))
throw(DomainError((class1,class2), "Some class types are out of range."))
Expand Down

0 comments on commit 33b5b48

Please sign in to comment.