Skip to content

Commit

Permalink
change cartan_symmetrizer and orientation of G2
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-roehrich committed Nov 26, 2024
1 parent 02f6c5c commit 4d78ac2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 81 deletions.
97 changes: 34 additions & 63 deletions experimental/LieAlgebras/src/CartanMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function cartan_matrix(fam::Symbol, rk::Int)
elseif fam == :F
mat = matrix(ZZ, [2 -1 0 0; -1 2 -1 0; 0 -2 2 -1; 0 0 -1 2])
elseif fam == :G
mat = matrix(ZZ, [2 -3; -1 2])
mat = matrix(ZZ, [2 -1; -3 2])
else
error("Unreachable")
end
Expand Down Expand Up @@ -169,6 +169,9 @@ where $a_{ij}$ are the entries of the Cartan matrix `gcm`.
If `check=true` the function will verify that `gcm` is indeed a generalized Cartan matrix.
!!! warning
Currently only Cartan matrices of finite type are supported.
# Examples
```jldoctest
julia> cartan_symmetrizer(cartan_matrix(:B, 2))
Expand All @@ -178,69 +181,37 @@ julia> cartan_symmetrizer(cartan_matrix(:B, 2))
```
"""
function cartan_symmetrizer(gcm::ZZMatrix; check::Bool=true)
check && @req is_cartan_matrix(gcm) "not a Cartan matrix"
rk = nrows(gcm)
diag = ones(ZZRingElem, rk)

# used for traversal
undone = trues(rk)
plan = zeros(Int, rk) # roots planned sorted asc grouped by component
head = 0
tail = 0

# we collect roots of the same length
# once we know if they are short or long we scale approriately
while any(undone)
if head == tail
head += 1
plan[head] = findfirst(undone)::Int
undone[plan[head]] = false
end

prev = head
i = plan[head]
for j in 1:rk
if i == j
continue
ct, ord = cartan_type_with_ordering(gcm; check=check)

i = 1
d = ones(ZZRingElem, length(ord))
for (fam, rk) in ct
if fam == :A
i += rk
elseif fam == :B
for j in i:(i + rk - 2)
d[j] = 2
end

if !undone[j] || is_zero_entry(gcm, i, j)
continue
end

head += 1
plan[head] = j
undone[j] = false

if diag[i] * gcm[i, j] == diag[j] * gcm[j, i]
continue
elseif gcm[i, j] == gcm[j, i]
diag[i] = lcm(diag[i], diag[j])
diag[j] = diag[i]
continue
end

if gcm[j, i] < -1
tail += 1
v = -gcm[j, i]
while tail < head
diag[plan[tail]] *= v
tail += 1
end
end
if gcm[i, j] < -1
diag[j] *= -gcm[i, j]
tail = head - 1
end
end

# we found new roots, meaning we are done with this component of the root system
if prev == head
tail = head
i += rk
elseif fam == :C
i += rk
d[i-1] = 2
elseif fam == :D
i += rk
elseif fam == :E
i += rk
elseif fam == :F
d[i] = d[i+1] = 2
i += rk
elseif fam == :G
d[i] = 3
i += rk
else
error("unreachable")
end
end

return diag
return invpermute!(d, ord)
end

@doc raw"""
Expand Down Expand Up @@ -366,10 +337,10 @@ function cartan_type_with_ordering(gcm::ZZMatrix; check::Bool=true)
push!(ord, v0, v1)
elseif gcm[v0, v1] == -3
push!(type, (:G, 2))
push!(ord, v0, v1)
push!(ord, v1, v0)
elseif gcm[v1, v0] == -3
push!(type, (:G, 2))
push!(ord, v1, v0)
push!(ord, v0, v1)
else
error("unreachable")
end
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/DynkinDiagram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function show_dynkin_diagram(fam::Symbol, rk::Int, labels::AbstractVector{Int})
D = "$(labels[1]) - $(labels[2]) >=> $(labels[3]) - $(labels[4])"
elseif fam == :G
@assert rk == 2
D = "$(labels[1]) <<< $(labels[2])"
D = "$(labels[1]) >>> $(labels[2])"
end
isempty(D) && error("Unreachable")
print(D)
Expand Down
41 changes: 24 additions & 17 deletions experimental/LieAlgebras/test/CartanMatrix-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,38 @@
@test cartan_symmetrizer(cartan_matrix(:E, 7)) == [1, 1, 1, 1, 1, 1, 1]
@test cartan_symmetrizer(cartan_matrix(:E, 8)) == [1, 1, 1, 1, 1, 1, 1, 1]
@test cartan_symmetrizer(cartan_matrix(:F, 4)) == [2, 2, 1, 1]
@test cartan_symmetrizer(cartan_matrix(:G, 2)) == [1, 3]
@test cartan_symmetrizer(cartan_matrix(:G, 2)) == [3, 1]

# affine type
@test cartan_symmetrizer(ZZ[2 -2; -2 2]) == [1, 1] # A1~1
@test cartan_symmetrizer(ZZ[2 -2 0; -1 2 -1; 0 -2 2]) == [1, 2, 1] # D3~2
@test cartan_symmetrizer(ZZ[2 -4; -1 2]) == [1, 4] # A1~2
#@test cartan_symmetrizer(ZZ[2 -2; -2 2]) == [1, 1] # A1~1
#@test cartan_symmetrizer(ZZ[2 -2 0; -1 2 -1; 0 -2 2]) == [1, 2, 1] # D3~2
#@test cartan_symmetrizer(ZZ[2 -4; -1 2]) == [1, 4] # A1~2

# hyperbolic type
@test cartan_symmetrizer(ZZ[2 -2; -3 2]) == [3, 2]
#@test cartan_symmetrizer(ZZ[2 -2; -3 2]) == [3, 2]
end

@testset "cartan_bilinear_form" begin
function test_cartan_bilinear_form(cm::ZZMatrix)
rk = nrows(cm)
for _ in 1:50
i, j = rand(1:rk, 2)
if i != j
swap_rows!(cm, i, j)
swap_cols!(cm, i, j)
for _ in 1:10
for _ in 1:10
i, j = rand(1:rk, 2)
if i != j
swap_rows!(cm, i, j)
swap_cols!(cm, i, j)
end
end

bil = cartan_bilinear_form(cm)
if !is_symmetric(bil)
println(cm)
println(bil)
break
end
@test is_symmetric(bil) == true
@test all(cm[i, j] == div(2 * bil[i, j], bil[i, i]) for i in 1:rk, j in 1:rk)
end

bil = cartan_bilinear_form(cm)
@test is_symmetric(bil) == true
@test all(cm[i, j] == div(2 * bil[i, j], bil[i, i]) for i in 1:rk, j in 1:rk)
end

# irreducible matrices
Expand All @@ -148,9 +155,9 @@
test_cartan_bilinear_form(cartan_matrix((:F, 4), (:B, 2), (:E, 7), (:G, 2)))

# affine type
@test cartan_bilinear_form(ZZ[2 -2; -2 2]) == ZZ[2 -2; -2 2]
@test cartan_bilinear_form(ZZ[2 -2 0; -1 2 -1; 0 -2 2]) == ZZ[2 -2 0; -2 4 -2; 0 -2 2]
@test cartan_bilinear_form(ZZ[2 -4; -1 2]) == ZZ[2 -4; -4 8]
#@test cartan_bilinear_form(ZZ[2 -2; -2 2]) == ZZ[2 -2; -2 2]
#@test cartan_bilinear_form(ZZ[2 -2 0; -1 2 -1; 0 -2 2]) == ZZ[2 -2 0; -2 4 -2; 0 -2 2]
#@test cartan_bilinear_form(ZZ[2 -4; -1 2]) == ZZ[2 -4; -4 8]
end

@testset "cartan_type_with_ordering" begin
Expand Down

0 comments on commit 4d78ac2

Please sign in to comment.