Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 9, 2023
1 parent 41118ff commit 4b4c77f
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 136 deletions.
11 changes: 7 additions & 4 deletions experimental/LieAlgebras/src/LieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ function lie_algebra(
cached::Bool=true,
)
@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))
if GAPWrap.IsFiniteDimensional(gapL)
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))
end
end
error("Not implemented.")
end
10 changes: 6 additions & 4 deletions experimental/LieAlgebras/src/iso_gap_oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
###############################################################################

function _iso_gap_oscar_lie_algebra(F::GAP.GapObj)
if GAPWrap.IsLieObjectCollection(F)
return _iso_gap_oscar_linear_lie_algebra(F)
else
return _iso_gap_oscar_abstract_lie_algebra(F)
if GAPWrap.IsFiniteDimensional(F)
if GAPWrap.IsLieObjectCollection(F)
return _iso_gap_oscar_linear_lie_algebra(F)
else
return _iso_gap_oscar_abstract_lie_algebra(F)
end
end

error("no method found")
Expand Down
106 changes: 43 additions & 63 deletions experimental/LieAlgebras/test/iso_gap_oscar-test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
import Oscar: GAPWrap

num_random_tests = 10
function test_iso_gap_oscar(LG, oscarT; num_random_tests::Int=10)
iso = Oscar.iso_gap_oscar(LG)
@test domain(iso) == LG
LO = codomain(iso)
@test LO isa oscarT

@test codomain(Oscar.iso_oscar_gap(LO)) === LG

@test iso === Oscar.iso_gap_oscar(LG) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = preimage(iso, x)
y_ = preimage(iso, y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test iso(x_) == x
@test iso(y_) == y

# f homomorphic
@test iso(2 * x_) == 2 * iso(x_)
@test iso(x_ + y_) == iso(x_) + iso(y_)
@test iso(x_ * y_) == iso(x_) * iso(y_)

# f^-1 homomorphic
@test preimage(iso, 2 * x) == 2 * preimage(iso, x)
@test preimage(iso, x + y) == preimage(iso, x) + preimage(iso, y)
@test preimage(iso, x * y) == preimage(iso, x) * preimage(iso, y)
end
end

@testset "LieAlgebras.iso_gap_oscar" begin
baserings = [GAP.Globals.Rationals, GAPWrap.CF(4)]
Expand All @@ -19,38 +53,7 @@ num_random_tests = 10
]

@testset for LG in lie_algebras
iso = Oscar.iso_gap_oscar(LG)
@test domain(iso) == LG
LO = codomain(iso)
@test LO isa AbstractLieAlgebra
@test codomain(Oscar.iso_oscar_gap(LO)) === LG

@test iso == Oscar.iso_gap_oscar(LG) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = preimage(iso, x)
y_ = preimage(iso, y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test iso(x_) == x
@test iso(y_) == y

# f homomorphic
@test iso(2 * x_) == 2 * iso(x_)
@test iso(x_ + y_) == iso(x_) + iso(y_)
@test iso(x_ * y_) == iso(x_) * iso(y_)

# f^-1 homomorphic
@test preimage(iso, 2 * x) == 2 * preimage(iso, x)
@test preimage(iso, x + y) == preimage(iso, x) + preimage(iso, y)
@test preimage(iso, x * y) == preimage(iso, x) * preimage(iso, y)
end
test_iso_gap_oscar(LG, AbstractLieAlgebra)
end
end

Expand All @@ -72,38 +75,15 @@ num_random_tests = 10
]

@testset for LG in lie_algebras
iso = Oscar.iso_gap_oscar(LG)
@test domain(iso) == LG
LO = codomain(iso)
@test LO isa LinearLieAlgebra
@test codomain(Oscar.iso_oscar_gap(LO)) === LG

@test iso == Oscar.iso_gap_oscar(LG) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = preimage(iso, x)
y_ = preimage(iso, y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test iso(x_) == x
@test iso(y_) == y
test_iso_gap_oscar(LG, LinearLieAlgebra)
end
end

# f homomorphic
@test iso(2 * x_) == 2 * iso(x_)
@test iso(x_ + y_) == iso(x_) + iso(y_)
@test iso(x_ * y_) == iso(x_) * iso(y_)
@testset "Infinite dimensional Lie algebra" begin
lie_algebras = [GAP.Globals.FreeLieAlgebra(RG, 1), GAP.Globals.FreeLieAlgebra(RG, 2)]

# f^-1 homomorphic
@test preimage(iso, 2 * x) == 2 * preimage(iso, x)
@test preimage(iso, x + y) == preimage(iso, x) + preimage(iso, y)
@test preimage(iso, x * y) == preimage(iso, x) * preimage(iso, y)
end
@testset for LG in lie_algebras
@test_throws ErrorException Oscar.iso_gap_oscar(LG)
end
end
end
Expand Down
101 changes: 36 additions & 65 deletions experimental/LieAlgebras/test/iso_oscar_gap-test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
import Oscar: GAPWrap

num_random_tests = 10
function test_iso_oscar_gap(LO::LieAlgebra; num_random_tests::Int=10)
iso = Oscar.iso_oscar_gap(LO)
@test domain(iso) == LO
LG = codomain(iso)
@test GAPWrap.IsLieAlgebra(LG)
# @test codomain(Oscar.iso_gap_oscar(LG)) === LO

@test iso === Oscar.iso_oscar_gap(LO) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = iso(x)
y_ = iso(y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test preimage(iso, x_) == x
@test preimage(iso, y_) == y

# f homomorphic
@test iso(2 * x) == 2 * iso(x)
@test iso(x + y) == iso(x) + iso(y)
@test iso(x * y) == iso(x) * iso(y)

# f^-1 homomorphic
@test preimage(iso, 2 * x_) == 2 * preimage(iso, x_)
@test preimage(iso, x_ + y_) == preimage(iso, x_) + preimage(iso, y_)
@test preimage(iso, x_ * y_) == preimage(iso, x_) * preimage(iso, y_)
end
end

@testset "LieAlgebras.iso_oscar_gap" begin
baserings = [QQ, cyclotomic_field(4)[1]]
Expand All @@ -25,38 +58,7 @@ num_random_tests = 10
]

@testset for LO in lie_algebras
iso = Oscar.iso_oscar_gap(LO)
@test domain(iso) == LO
LG = codomain(iso)
@test GAPWrap.IsLieAlgebra(LG)
# @test codomain(Oscar.iso_gap_oscar(LG)) === LO

@test iso == Oscar.iso_oscar_gap(LO) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = iso(x)
y_ = iso(y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test preimage(iso, x_) == x
@test preimage(iso, y_) == y

# f homomorphic
@test iso(2 * x) == 2 * iso(x)
@test iso(x + y) == iso(x) + iso(y)
@test iso(x * y) == iso(x) * iso(y)

# f^-1 homomorphic
@test preimage(iso, 2 * x_) == 2 * preimage(iso, x_)
@test preimage(iso, x_ + y_) == preimage(iso, x_) + preimage(iso, y_)
@test preimage(iso, x_ * y_) == preimage(iso, x_) * preimage(iso, y_)
end
test_iso_oscar_gap(LO)
end
end

Expand All @@ -68,38 +70,7 @@ num_random_tests = 10
]

@testset for LO in lie_algebras
iso = Oscar.iso_oscar_gap(LO)
@test domain(iso) == LO
LG = codomain(iso)
@test GAPWrap.IsLieAlgebra(LG)
# @test codomain(Oscar.iso_gap_oscar(LG)) === LO

@test iso == Oscar.iso_oscar_gap(LO) # test caching

for _ in 1:num_random_tests
x = LO(rand(-10:10, dim(LO)))
y = LO(rand(-10:10, dim(LO)))
x_ = iso(x)
y_ = iso(y)

# mapping non-zero to non-zero
@test iszero(x) == iszero(x_)
@test iszero(y) == iszero(y_)

# self-inverse
@test preimage(iso, x_) == x
@test preimage(iso, y_) == y

# f homomorphic
@test iso(2 * x) == 2 * iso(x)
@test iso(x + y) == iso(x) + iso(y)
@test iso(x * y) == iso(x) * iso(y)

# f^-1 homomorphic
@test preimage(iso, 2 * x_) == 2 * preimage(iso, x_)
@test preimage(iso, x_ + y_) == preimage(iso, x_) + preimage(iso, y_)
@test preimage(iso, x_ * y_) == preimage(iso, x_) * preimage(iso, y_)
end
test_iso_oscar_gap(LO)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/GAP/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ GAP.@wrap IsFFE(x::Any)::Bool
GAP.@wrap IsFFECollCollColl(x::Any)::Bool
GAP.@wrap IsField(x::Any)::Bool
GAP.@wrap IsFinite(x::Any)::Bool
GAP.@wrap IsFiniteDimensional(x::Any)::Bool
GAP.@wrap IsFinitelyGeneratedGroup(x::Any)::Bool
GAP.@wrap IsFpGroup(x::Any)::Bool
GAP.@wrap IsFreeGroup(x::Any)::Bool
Expand Down

0 comments on commit 4b4c77f

Please sign in to comment.