Skip to content

Commit

Permalink
Move root system iso to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 22, 2024
1 parent 241ac1f commit 68cdc5d
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions experimental/LieAlgebras/src/iso_oscar_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function _iso_oscar_gap_lie_algebra_functions(
return (f, finv)
end

function _iso_oscar_gap(LO::LinearLieAlgebra)
function _iso_oscar_gap(LO::LinearLieAlgebra; set_attributes::Bool=true)
coeffs_iso = Oscar.iso_oscar_gap(coefficient_ring(LO))
LG = GAP.Globals.LieAlgebra(
codomain(coeffs_iso),
Expand All @@ -32,6 +32,12 @@ function _iso_oscar_gap(LO::LinearLieAlgebra)

f, finv = _iso_oscar_gap_lie_algebra_functions(LO, LG, coeffs_iso)

if set_attributes && has_root_system(LO)
# we need to construct the root system in GAP as otherwise it may detect a different order of simple roots
RO = root_system(LO)
_iso_oscar_gap_set_root_system(LG, RO)
end

return MapFromFunc(LO, LG, f, finv)
end

Expand Down Expand Up @@ -59,34 +65,38 @@ function _iso_oscar_gap(LO::AbstractLieAlgebra; set_attributes::Bool=true)
if set_attributes && has_root_system(LO)
# we need to construct the root system in GAP as otherwise it may detect a different order of simple roots
RO = root_system(LO)
RG = GAP.Globals.Objectify(
GAP.Globals.NewType(
GAP.Globals.NewFamily(GAP.Obj("RootSystemFam"), GAP.Globals.IsObject),
GAP.evalstr("IsAttributeStoringRep and IsRootSystemFromLieAlgebra")),
GAP.GapObj(Dict{Symbol,Any}()))
GAP.Globals.SetUnderlyingLieAlgebra(RG, LG)

cartan_trO = transpose(cartan_matrix(RO))
transform_root(r::RootSpaceElem) = GAP.Obj(coefficients(r) * cartan_trO)[1]
GAP.Globals.SetPositiveRoots(RG, GAP.Obj(transform_root.(positive_roots(RO))))
GAP.Globals.SetNegativeRoots(RG, GAP.Obj(transform_root.(negative_roots(RO))))
GAP.Globals.SetSimpleSystem(RG, GAP.Obj(transform_root.(simple_roots(RO))))
can_basisG = GAP.Globals.CanonicalBasis(LG)
pos_root_vectorsG = can_basisG[1:n_positive_roots(RO)]
neg_root_vectorsG = can_basisG[(n_positive_roots(RO) + 1):(2 * n_positive_roots(RO))]
csa_basisG = can_basisG[(2 * n_positive_roots(RO) + 1):end]
GAP.Globals.SetPositiveRootVectors(RG, pos_root_vectorsG)
GAP.Globals.SetNegativeRootVectors(RG, neg_root_vectorsG)
GAP.Globals.SetCanonicalGenerators(
RG, GAP.Obj([pos_root_vectorsG, neg_root_vectorsG, csa_basisG])
)
GAP.Globals.SetChevalleyBasis(
LG, GAP.Obj([pos_root_vectorsG, neg_root_vectorsG, csa_basisG])
)

GAP.Globals.SetCartanMatrix(RG, GAP.Obj(cartan_trO))
GAP.Globals.SetRootSystem(LG, RG)
_iso_oscar_gap_set_root_system(LG, RO)
end

return MapFromFunc(LO, LG, f, finv)
end

function _iso_oscar_gap_set_root_system(LG::GapObj, RO::RootSystem)
RG = GAP.Globals.Objectify(
GAP.Globals.NewType(
GAP.Globals.NewFamily(GAP.Obj("RootSystemFam"), GAP.Globals.IsObject),
GAP.evalstr("IsAttributeStoringRep and IsRootSystemFromLieAlgebra")),
GAP.GapObj(Dict{Symbol,Any}()))
GAP.Globals.SetUnderlyingLieAlgebra(RG, LG)

cartan_trO = transpose(cartan_matrix(RO))
transform_root(r::RootSpaceElem) = GAP.Obj(coefficients(r) * cartan_trO)[1]
GAP.Globals.SetPositiveRoots(RG, GAP.Obj(transform_root.(positive_roots(RO))))
GAP.Globals.SetNegativeRoots(RG, GAP.Obj(transform_root.(negative_roots(RO))))
GAP.Globals.SetSimpleSystem(RG, GAP.Obj(transform_root.(simple_roots(RO))))
can_basisG = GAP.Globals.CanonicalBasis(LG)
pos_root_vectorsG = can_basisG[1:n_positive_roots(RO)]
neg_root_vectorsG = can_basisG[(n_positive_roots(RO) + 1):(2 * n_positive_roots(RO))]
csa_basisG = can_basisG[(2 * n_positive_roots(RO) + 1):end]
GAP.Globals.SetPositiveRootVectors(RG, pos_root_vectorsG)
GAP.Globals.SetNegativeRootVectors(RG, neg_root_vectorsG)
GAP.Globals.SetCanonicalGenerators(
RG, GAP.Obj([pos_root_vectorsG, neg_root_vectorsG, csa_basisG])
)
GAP.Globals.SetChevalleyBasis(
LG, GAP.Obj([pos_root_vectorsG, neg_root_vectorsG, csa_basisG])
)

GAP.Globals.SetCartanMatrix(RG, GAP.Obj(cartan_trO))
GAP.Globals.SetRootSystem(LG, RG)
end

0 comments on commit 68cdc5d

Please sign in to comment.