Skip to content

Commit

Permalink
LieAlgebras: Use more GAPWrap
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Apr 14, 2023
1 parent 6328b9d commit 4c93b5f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 5 additions & 5 deletions experimental/LieAlgebras/src/GapWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function _iso_oscar_gap_lie_algebra_functions(

f = function (x::LieAlgebraElem{C})
cfs = GAP.Obj([coeffs_iso(c) for c in coefficients(x)])
return GAP.Globals.LinearCombination(basis_LG, cfs)
return GAPWrap.LinearCombination(basis_LG, cfs)
end

finv = function (x)
Expand Down Expand Up @@ -66,8 +66,8 @@ function _iso_oscar_gap(LO::AbstractLieAlgebra{C}) where {C<:RingElement}
end

function _iso_gap_oscar(F::GAP.GapObj)
if GAP.Globals.IsLieAlgebra(F)
if GAP.Globals.IsLieObjectCollection(F)
if GAPWrap.IsLieAlgebra(F)
if GAPWrap.IsLieObjectCollection(F)
return _iso_gap_oscar_linear_lie_algebra(F)
else
return _iso_gap_oscar_abstract_lie_algebra(F)
Expand Down Expand Up @@ -135,11 +135,11 @@ end
function _linear_lie_algebra_from_GAP(
LG::GAP.GapObj, coeffs_iso::Map{GAP.GapObj}, s::Vector{<:VarName}; cached::Bool=true
)
@req GAP.Globals.IsLieObjectCollection(LG) "Input is not a linear Lie algebra."
@req GAPWrap.IsLieObjectCollection(LG) "Input is not a linear Lie algebra."

RO = codomain(coeffs_iso)
basis = [
map_entries(coeffs_iso, GAP.Globals.UnderlyingRingElement(b)) for b in GAPWrap.Basis(LG)
map_entries(coeffs_iso, GAPWrap.UnderlyingRingElement(b)) for b in GAPWrap.Basis(LG)
]
n = size(basis[1])[1]
LO = LinearLieAlgebra{elem_type(RO)}(RO, n, basis, Symbol.(s); cached)
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ function lie_algebra(
s::Vector{<:VarName}=[Symbol("x_$i") for i in 1:GAPWrap.Dimension(gapL)];
cached::Bool=true,
)
@req GAP.Globals.IsLieAlgebra(gapL) "gapL must be a Lie algebra."
if GAP.Globals.IsLieObjectCollection(gapL)
@req GAPWrap.IsLieAlgebra(gapL) "gapL must be a Lie algebra."
if GAPWrap.IsLieObjectCollection(gapL)
return codomain(_iso_gap_oscar_linear_lie_algebra(gapL, s; cached))
else
return codomain(_iso_gap_oscar_abstract_lie_algebra(gapL, s; cached))
Expand Down
8 changes: 5 additions & 3 deletions experimental/LieAlgebras/test/GapWrapper-test.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Oscar: GAPWrap

num_random_tests = 10

@testset "LieAlgebras.GapWrapper" begin
Expand Down Expand Up @@ -26,7 +28,7 @@ num_random_tests = 10
@testset for L in lie_algebras
iso = Oscar.LieAlgebras._iso_oscar_gap(L)
@test domain(iso) == L
@test GAP.Globals.IsLieAlgebra(codomain(iso))
@test GAPWrap.IsLieAlgebra(codomain(iso))

for _ in 1:num_random_tests
x = L(rand(-10:10, dim(L)))
Expand Down Expand Up @@ -67,7 +69,7 @@ num_random_tests = 10
@testset for L in lie_algebras
iso = Oscar.LieAlgebras._iso_oscar_gap(L)
@test domain(iso) == L
@test GAP.Globals.IsLieAlgebra(codomain(iso))
@test GAPWrap.IsLieAlgebra(codomain(iso))

for _ in 1:num_random_tests
x = L(rand(-10:10, dim(L)))
Expand Down Expand Up @@ -99,7 +101,7 @@ num_random_tests = 10
end

@testset "GAP -> Oscar" begin
baserings = [GAP.Globals.Rationals, GAP.Globals.CyclotomicField(4)]
baserings = [GAP.Globals.Rationals, GAPWrap.CF(4)]
@testset for RG in baserings
@testset "AbstractLieAlgebra" begin
lie_algebras = [
Expand Down
4 changes: 4 additions & 0 deletions src/GAP/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ GAP.@wrap IsIntegers(x::Any)::Bool
GAP.@wrap IsIrreducibleCharacter(x::Any)::Bool
GAP.@wrap IsLetterAssocWordRep(x::Any)::Bool
GAP.@wrap IsLetterWordsFamily(x::Any)::Bool
GAP.@wrap IsLieAlgebra(x::Any)::Bool
GAP.@wrap IsLieObjectCollection(x::Any)::Bool
GAP.@wrap IsList(x::Any)::Bool
GAP.@wrap IsMatrix(x::GapObj)::Bool
GAP.@wrap IsMatrixGroup(x::GapObj)::Bool
Expand Down Expand Up @@ -162,6 +164,7 @@ GAP.@wrap IsZmodnZObjNonprimeCollection(x::Any)::Bool
GAP.@wrap Iterator(x::Any)::GapObj
GAP.@wrap LargestMovedPoint(x::Any)::Int
GAP.@wrap LeftActingDomain(x::GapObj)::GapObj
GAP.@wrap LinearCombination(x::GapObj, y::GapObj)::GapObj
GAP.@wrap MinimalPolynomial(x::GapObj, y::GAP.Obj)::GapObj
GAP.@wrap mod(x::Any, y::Any)::GAP.Obj
GAP.@wrap NextIterator(x::GapObj)::Any
Expand Down Expand Up @@ -189,6 +192,7 @@ GAP.@wrap Source(x::GapObj)::GapObj
GAP.@wrap Sqrt(x::Int64)::GAP.Obj
GAP.@wrap StringViewObj(x::Any)::GapObj
GAP.@wrap UnderlyingElement(x::GapObj)::GapObj
GAP.@wrap UnderlyingRingElement(x::GapObj)::GapObj
GAP.@wrap UnivariatePolynomialByCoefficients(x::GapObj, y::GapObj, z::Int)::GapObj
GAP.@wrap Z(x::Any)::GAP.Obj
GAP.@wrap Zero(x::Any)::GAP.Obj
Expand Down

0 comments on commit 4c93b5f

Please sign in to comment.