Skip to content

Commit

Permalink
LieAlgebras: Remove additional layer of caching
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored and ThomasBreuer committed May 17, 2023
1 parent 45bc8d4 commit 5de301c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 51 deletions.
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/GapWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions experimental/LieAlgebras/src/LieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/iso_gap_oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
56 changes: 26 additions & 30 deletions experimental/LieAlgebras/src/iso_oscar_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5de301c

Please sign in to comment.