Skip to content

Commit

Permalink
add tests for characters multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Nov 29, 2023
1 parent 26fe52e commit 2847813
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Characters/class_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ function Base.:*(χ::Character, ψ::Character)
return Character(table(χ), __decompose(Int, values, table(χ)))
end

Base.:^::Character, n::Integer) = Base.power_by_squaring(χ, n)

## Group-theoretic functions:

PermutationGroups.degree::Character) = Int(χ(one(parent(χ))))
Expand Down
43 changes: 43 additions & 0 deletions test/characters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,49 @@
@test zero(χ) == Characters.Character(Characters.table(χ), zeros(5))
@test dot(χ, zero(χ)) == 0
@test dot(zero(χ), zero(χ)) == 0

@testset "characters multiplication: Sym(3)" begin
G = PermGroup(perm"(1,2,3)", perm"(1,2)")
tbl = Characters.CharacterTable(G)
χ = Characters.irreducible_characters(tbl)

# χ[1] - the trivial character
# χ[2] - the alternating character
# χ[3] - the non-trivial, degree-2 character

@test all(χ[1] * ψ == ψ for ψ in χ)
@test χ[2]^2 == χ[1]
@test χ[2] * χ[3] == χ[3] * χ[2] == χ[3]

@test χ[3]^2 == χ[1] + χ[2] + χ[3]
end

@testset "characters multiplication: Sym(4)" begin
G = PermGroup(perm"(1,2,3,4)", perm"(1,2)")
tbl = Characters.CharacterTable(G)
χ = Characters.irreducible_characters(tbl)

# χ[1] - the trivial character
# χ[2] - the alternating character
# χ[3] - the non-trivial, degree-2 character
# χ[4] - the non-trivial, degree-3 character
# χ[5] - χ[4]*χ[2]

@test all(χ[1] * ψ == ψ for ψ in χ)
@test χ[2]^2 == χ[1]
@test χ[2] * χ[3] == χ[3]
@test χ[2] * χ[4] == χ[5]
@test χ[2] * χ[5] == χ[4]

@test χ[3]^2 == χ[1] + χ[2] + χ[3]
@test χ[3] * χ[4] == χ[4] + χ[5]
@test χ[3] * χ[5] == χ[4] + χ[5]

@test χ[4]^2 == χ[1] + χ[3] + χ[4] + χ[5]
@test χ[4] * χ[5] == χ[2] + χ[3] + χ[4] + χ[5]

@test χ[5]^2 == χ[1] + χ[3] + χ[4] + χ[5]
end
end

@testset "Characters io" begin
Expand Down

0 comments on commit 2847813

Please sign in to comment.