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 conversion between OSCAR and GAP prime fields #3611

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
25 changes: 21 additions & 4 deletions src/GAP/iso_oscar_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ function _iso_oscar_gap(RO::Union{Nemo.zzModRing, Nemo.ZZModRing})
return MapFromFunc(RO, RG, f, finv)
end

# Assume that `FO` and `FG` are finite fields of the same order
# in Oscar and GAP, respectively.
function _iso_oscar_gap_field_finite_functions(FO::Union{Nemo.fpField, Nemo.FpField}, FG::GAP.GapObj)
_ffe_to_int(a::FqFieldElem) = Nemo._coeff(a, 0)
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
_ffe_to_int(a::FqPolyRepFieldElem) = coeff(a, 0)
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
_ffe_to_int(a::fqPolyRepFieldElem) = coeff(a, 0)
_ffe_to_int(a::Union{fpFieldElem,FpFieldElem}) = lift(a)

function _make_prime_field_functions(FO, FG)
e = GAPWrap.One(FG)

f(x) = GAP.Obj(lift(x))*e
f = function(x)
y = GAP.julia_to_gap(_ffe_to_int(x))::GapInt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasBreuer For now I removed the ZZ(...) from the one _ffe_to_int method and just call GAP.julia_to_gap here, that should work fine for now. On the long run my plan is to use GAP.GapInt instead, see oscar-system/GAP.jl#984

return y*e
end

finv = function(x::GAP.Obj)
y = GAPWrap.IntFFE(x)
Expand All @@ -70,6 +76,12 @@ function _iso_oscar_gap_field_finite_functions(FO::Union{Nemo.fpField, Nemo.FpFi
return (f, finv)
end

# Assume that `FO` and `FG` are finite fields of the same order
# in Oscar and GAP, respectively.
function _iso_oscar_gap_field_finite_functions(FO::Union{Nemo.fpField, Nemo.FpField}, FG::GAP.GapObj)
return _make_prime_field_functions(FO, FG)
end

function _iso_oscar_gap_field_finite_functions(FO::Union{FqPolyRepField, FqField, fqPolyRepField}, FG::GAP.GapObj)
p = characteristic(FO)
d = degree(FO)
Expand All @@ -83,6 +95,11 @@ function _iso_oscar_gap_field_finite_functions(FO::Union{FqPolyRepField, FqField
error("extensions of extension fields are not supported")
end

# handle prime fields first
if d == 1
return _make_prime_field_functions(FO, FG)
end

# Compute the canonical basis of `FG`.
basis_FG = GAPWrap.Basis(FG)
# Test that we do not run into the problem from
Expand Down
Loading