From 5de301c7ed3d8774edf43f472a34b29614dd0acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 9 May 2023 10:39:50 +0200 Subject: [PATCH] LieAlgebras: Remove additional layer of caching --- experimental/LieAlgebras/src/GapWrapper.jl | 2 +- experimental/LieAlgebras/src/LieAlgebra.jl | 18 ------ experimental/LieAlgebras/src/iso_gap_oscar.jl | 4 +- experimental/LieAlgebras/src/iso_oscar_gap.jl | 56 +++++++++---------- 4 files changed, 29 insertions(+), 51 deletions(-) diff --git a/experimental/LieAlgebras/src/GapWrapper.jl b/experimental/LieAlgebras/src/GapWrapper.jl index 27d1837ade8e..bca45d8e972b 100644 --- a/experimental/LieAlgebras/src/GapWrapper.jl +++ b/experimental/LieAlgebras/src/GapWrapper.jl @@ -10,7 +10,7 @@ function lie_algebra_highest_weight_module_struct_consts_gap( R = base_ring(L) isoR = Oscar.iso_oscar_gap(R) - gapL = codomain(_iso_oscar_gap(L)) + gapL = codomain(Oscar.iso_oscar_gap(L)) dimL = GAPWrap.Dimension(gapL) @assert dimL == dim(L) basisL = GAPWrap.Basis(gapL) diff --git a/experimental/LieAlgebras/src/LieAlgebra.jl b/experimental/LieAlgebras/src/LieAlgebra.jl index 56951af68105..4b2c52c75c25 100644 --- a/experimental/LieAlgebras/src/LieAlgebra.jl +++ b/experimental/LieAlgebras/src/LieAlgebra.jl @@ -193,24 +193,6 @@ function Base.hash(x::LieAlgebraElem{C}, h::UInt) where {C<:RingElement} return xor(hash(coefficients(x), hash(parent(x), h)), b) end -############################################################################### -# -# Isomorphism to GAP accessors -# -############################################################################### - -# currently, the user should only use _iso_oscar_gap(LO) to get the isomorphism - -function _get_iso_oscar_gap!(f, LO::LieAlgebra{C}) where {C<:RingElement} - get_attribute!(f, LO, :iso_oscar_gap)::Map{typeof(LO),GAP.GapObj} -end - -function _set_iso_oscar_gap!( - LO::LieAlgebra{C}, iso::Map{<:LieAlgebra{C},GAP.GapObj} -) where {C<:RingElement} - set_attribute!(LO, :iso_oscar_gap => iso) -end - ############################################################################### # # Constructor diff --git a/experimental/LieAlgebras/src/iso_gap_oscar.jl b/experimental/LieAlgebras/src/iso_gap_oscar.jl index cd14eba773ea..aa86cb35ea69 100644 --- a/experimental/LieAlgebras/src/iso_gap_oscar.jl +++ b/experimental/LieAlgebras/src/iso_gap_oscar.jl @@ -28,7 +28,7 @@ function _iso_gap_oscar_abstract_lie_algebra( finv, f = _iso_oscar_gap_lie_algebra_functions(LO, LG, inv(coeffs_iso)) iso = MapFromFunc(f, finv, LG, LO) - _set_iso_oscar_gap!(LO, inv(iso)) + set_attribute!(LO, :iso_oscar_gap => inv(iso)) return iso end @@ -42,7 +42,7 @@ function _iso_gap_oscar_linear_lie_algebra( finv, f = _iso_oscar_gap_lie_algebra_functions(LO, LG, inv(coeffs_iso)) iso = MapFromFunc(f, finv, LG, LO) - _set_iso_oscar_gap!(LO, inv(iso)) + set_attribute!(LO, :iso_oscar_gap => inv(iso)) return iso end diff --git a/experimental/LieAlgebras/src/iso_oscar_gap.jl b/experimental/LieAlgebras/src/iso_oscar_gap.jl index a148b14fd09b..36afce24d7bf 100644 --- a/experimental/LieAlgebras/src/iso_oscar_gap.jl +++ b/experimental/LieAlgebras/src/iso_oscar_gap.jl @@ -23,44 +23,40 @@ function _iso_oscar_gap_lie_algebra_functions( end function _iso_oscar_gap(LO::LinearLieAlgebra{C}) where {C<:RingElement} - _get_iso_oscar_gap!(LO) do - coeffs_iso = Oscar.iso_oscar_gap(base_ring(LO)) - LG = GAP.Globals.LieAlgebra( - codomain(coeffs_iso), - GAP.Obj([map_entries(coeffs_iso, xi) for xi in matrix_repr_basis(LO)]), - GAP.Obj("basis"), - ) + coeffs_iso = Oscar.iso_oscar_gap(base_ring(LO)) + LG = GAP.Globals.LieAlgebra( + codomain(coeffs_iso), + GAP.Obj([map_entries(coeffs_iso, xi) for xi in matrix_repr_basis(LO)]), + GAP.Obj("basis"), + ) - f, finv = _iso_oscar_gap_lie_algebra_functions(LO, LG, coeffs_iso) + f, finv = _iso_oscar_gap_lie_algebra_functions(LO, LG, coeffs_iso) - MapFromFunc(f, finv, LO, LG) - end + return MapFromFunc(f, finv, LO, LG) end function _iso_oscar_gap(LO::AbstractLieAlgebra{C}) where {C<:RingElement} - _get_iso_oscar_gap!(LO) do - coeffs_iso = Oscar.iso_oscar_gap(base_ring(LO)) - sc_table_G = [ + coeffs_iso = Oscar.iso_oscar_gap(base_ring(LO)) + sc_table_G = [ + [ [ - [ - begin - pairs = filter( - pair -> !iszero(last(pair)), collect(enumerate(Generic._matrix(xi * xj))) - ) - (map(first, pairs), GAP.Obj[coeffs_iso(c) for c in map(last, pairs)]) - end for xj in basis(LO) - ] for xi in basis(LO) - ] - -1 - coeffs_iso(zero(base_ring(LO))) + begin + pairs = filter( + pair -> !iszero(last(pair)), collect(enumerate(Generic._matrix(xi * xj))) + ) + (map(first, pairs), GAP.Obj[coeffs_iso(c) for c in map(last, pairs)]) + end for xj in basis(LO) + ] for xi in basis(LO) ] + -1 + coeffs_iso(zero(base_ring(LO))) + ] - LG = GAP.Globals.LieAlgebraByStructureConstants( - codomain(coeffs_iso), GAP.Obj(sc_table_G; recursive=true) - ) + LG = GAP.Globals.LieAlgebraByStructureConstants( + codomain(coeffs_iso), GAP.Obj(sc_table_G; recursive=true) + ) - f, finv = _iso_oscar_gap_lie_algebra_functions(LO, LG, coeffs_iso) + f, finv = _iso_oscar_gap_lie_algebra_functions(LO, LG, coeffs_iso) - MapFromFunc(f, finv, LO, LG) - end + return MapFromFunc(f, finv, LO, LG) end