Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing affordable_real and related tests #86

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
19 changes: 12 additions & 7 deletions src/sa_basis.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
function affordable_real(
irreducible_characters,
multiplicities = fill(1, length(irreducible_characters)),
multiplicities,
)
irr_real = similar(irreducible_characters, 0)
mls_real = similar(multiplicities, 0)
for (i, χ) in pairs(irreducible_characters)
ι = Characters.frobenius_schur(χ)
if abs(ι) == 1 # real or quaternionic
@debug "real/quaternionic:" χ
if ι == 1 # real
@debug "real" χ
push!(irr_real, χ)
push!(mls_real, multiplicities[i])
else # complex one...
elseif ι == -1 # quaternionic
@debug "quaternionic" χ
@assert iseven(multiplicities[i]) "Multiplicities of quaternionic character must be even."
push!(irr_real, 2 * χ)
push!(mls_real, div(multiplicities[i], 2))
else # complex
cχ = conj(χ)
k = findfirst(==(cχ), irreducible_characters)
@assert k !== nothing
@assert k !== nothing "Conjugate character not found."
@debug "complex" χ conj(χ) = irreducible_characters[k]
if k > i # ... we haven't already observed a conjugate of
@assert multiplicities[i] == multiplicities[k]
if k > i # we haven't already observed a conjugate
@assert multiplicities[i] == multiplicities[k] "Multiplicities of complex conjugates must be equal."
push!(irr_real, χ + cχ)
push!(mls_real, multiplicities[i])
end
Expand Down
24 changes: 23 additions & 1 deletion test/projections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end
G = PermGroup([perm"(1,2,3,4)"])
chars = let irr = SymbolicWedderburn.irreducible_characters(G)
if !all(isreal, irr)
irr, _ = SymbolicWedderburn.affordable_real(irr)
irr, _ = SymbolicWedderburn.affordable_real(irr,fill(1, length(irr)))
end
SymbolicWedderburn.Character{Float64}.(irr)
end
Expand Down Expand Up @@ -64,3 +64,25 @@ end
end
end
end

@testset "affordable real all cases" begin
G = SmallPermGroups[24][3] # SL(2,3)
tbl = SymbolicWedderburn.CharacterTable(Rational{Int}, G)
chars = SymbolicWedderburn.irreducible_characters(tbl)

@test SymbolicWedderburn.degree.(chars)==[1, 1, 1, 2, 2, 2, 3]
@test all(χ -> isone(dot(χ, χ)), chars)
chars_fl = SymbolicWedderburn.Character{ComplexF64}.(chars)
@test SymbolicWedderburn.degree.(chars_fl)==[1, 1, 1, 2, 2, 2, 3]
@test all(χ -> isapprox(dot(χ, χ), 1), chars_fl)



charsR, _ = SymbolicWedderburn.affordable_real(chars,fill(2,length(chars)))
@test SymbolicWedderburn.degree.(charsR) == [1, 2, 4, 4, 3]
@test [dot(χ, χ) for χ in charsR] == [1, 2, 2, 4, 1]

charsR_fl = SymbolicWedderburn.Character{Float64}.(charsR)
@test all( [1, 2, 4, 4, 3] .== SymbolicWedderburn.degree.(charsR_fl),)
@test all( [1, 2, 2, 4, 1].≈[dot(χ, χ) for χ in charsR_fl],)
end
2 changes: 1 addition & 1 deletion test/sa_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@test all(isone ∘ SymbolicWedderburn.degree, chars_fl)
@test all(χ -> isapprox(dot(χ, χ), 1), chars_fl)

charsR, _ = SymbolicWedderburn.affordable_real(chars)
charsR, _ = SymbolicWedderburn.affordable_real(chars,fill(1, length(chars)))
@test SymbolicWedderburn.degree.(charsR) ==
[dot(χ, χ) for χ in charsR] ==
[1, 1, 2, 2, 2, 2]
Expand Down
Loading