Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve ring_iso_oscar_gap for finite fields #808

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Groups/matrices/iso_oscar_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ end
function ring_iso_oscar_gap(F::T) where T <: Union{Nemo.FqNmodFiniteField, Nemo.FqFiniteField}
p = characteristic(F)
d = degree(F)
Fp_gap = GAP.Globals.GF(GAP.Obj(p)) # the prime field in GAP
p_gap = GAP.Obj(p)
Fp_gap = GAP.Globals.GF(p_gap) # the prime field in GAP
e = GAP.Globals.One(Fp_gap)

# prime fields are easy and efficient to deal with, handle them seperately
Expand All @@ -53,7 +54,14 @@ function ring_iso_oscar_gap(F::T) where T <: Union{Nemo.FqNmodFiniteField, Nemo.
f_gap = GAP.Globals.UnivariatePolynomial(Fp_gap, L_gap)

# ... and compute a GAP field G defined via this polynomial
G = GAP.Globals.GF(Fp_gap, f_gap)
# (If the given polynomial is a Conway polynomial then we may call
# GAP's `GF(p, d)`, which avoids GAP's `AlgebraicExtension`.)
if GAP.Globals.IsCheapConwayPolynomial(p_gap, d) &&
f_gap == GAP.Globals.ConwayPolynomial(p_gap, d)
G = GAP.Globals.GF(p_gap, d)
else
G = GAP.Globals.GF(Fp_gap, f_gap)
end

# compute matching bases of both fields
if GAP.Globals.IsAlgebraicExtension(G)
Expand Down
7 changes: 6 additions & 1 deletion test/Groups/matrixgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
end

# Test a large non-prime field.
F, _ = GF(next_prime(10^6), 2)
# (Oscar chooses a polynomial that is not a Conway polynomial.)
p = next_prime(10^6)
F, _ = GF(p, 2)
f = Oscar.ring_iso_oscar_gap(F)
for x in [ F(3), gen(F) ]
a = f(x)
@test preimage(f, a) == x
end
@test GAP.Globals.DefiningPolynomial(codomain(f)) !=
GAP.Globals.ConwayPolynomial(p, 2)
@test GAP.Globals.IsAlgebraicExtension(codomain(f))

F = GF(29,1)[1]
z = F(2)
Expand Down