Skip to content

Commit

Permalink
Adjust for FLINT 3.1 fq_nmod changes
Browse files Browse the repository at this point in the history
  • Loading branch information
albinahlback committed Jan 17, 2024
1 parent 7037349 commit a6b9f1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,6 @@ A finite field. Implemented as $\mathbb F_p[t]/f$ for the prime $p$ being an [`I
See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyRepFieldElem`](@ref) for elements.
"""
@attributes mutable struct fqPolyRepField <: FinField
p :: Int
n :: Int
ninv :: Int
norm :: Int
Expand All @@ -2237,19 +2236,23 @@ See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyR
overfields :: Dict{Int, Vector{FinFieldMorphism}}
subfields :: Dict{Int, Vector{FinFieldMorphism}}

function fqPolyRepField(c::ZZRingElem, deg::Int, s::Symbol, cached::Bool = true; check::Bool = true)
function fqPolyRepField(c::UInt, deg::Int, s::Symbol, cached::Bool = true; check::Bool = true)
check && !is_prime(c) &&
throw(DomainError(c, "the characteristic must be a prime"))
return get_cached!(FqNmodFiniteFieldID, (c, deg, s), cached) do
d = new()
ccall((:fq_nmod_ctx_init, libflint), Nothing,
(Ref{fqPolyRepField}, Ref{ZZRingElem}, Int, Ptr{UInt8}),
d, c, deg, string(s))
ccall((:fq_nmod_ctx_init_ui, libflint), Nothing,
(Ref{fqPolyRepField}, UInt, Int, Ptr{UInt8}),
d, c, deg, string(s))
finalizer(_FqNmodFiniteField_clear_fn, d)
return d
end
end

function fqPolyRepField(c::T, deg::Int, s::Symbol, cached::Bool = true; check::Bool = true) where T <: Union{Int, ZZRingElem}
return fqPolyRepField(UInt(c), deg, s, cached, check = check)
end

function fqPolyRepField(f::zzModPolyRingElem, s::Symbol, cached::Bool = true; check::Bool = true)
check && !is_prime(modulus(f)) &&
throw(DomainError(base_ring(f), "the base ring of the polynomial must be a field"))
Expand Down Expand Up @@ -2277,7 +2280,7 @@ See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyR

end

const FqNmodFiniteFieldID = CacheDictType{Tuple{ZZRingElem, Int, Symbol}, fqPolyRepField}()
const FqNmodFiniteFieldID = CacheDictType{Tuple{UInt, Int, Symbol}, fqPolyRepField}()

const FqNmodFiniteFieldIDNmodPol = CacheDictType{Tuple{zzModPolyRing, zzModPolyRingElem, Symbol},
fqPolyRepField}()
Expand Down
8 changes: 2 additions & 6 deletions src/flint/fq_nmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ is_unit(a::fqPolyRepFieldElem) = ccall((:fq_nmod_is_invertible, libflint), Bool,
(Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), a, a.parent)

function characteristic(a::fqPolyRepField)
d = ZZRingElem()
ccall((:__fq_nmod_ctx_prime, libflint), Nothing,
(Ref{ZZRingElem}, Ref{fqPolyRepField}), d, a)
return d
return ccall((:fq_nmod_ctx_prime, libflint), UInt, (Ref{fqPolyRepField},), a)
end

function order(a::fqPolyRepField)
Expand All @@ -116,8 +113,7 @@ function order(a::fqPolyRepField)
end

function degree(a::fqPolyRepField)
return ccall((:fq_nmod_ctx_degree, libflint), Int,
(Ref{fqPolyRepField},), a)
return ccall((:fq_nmod_ctx_degree, libflint), Int, (Ref{fqPolyRepField},), a)
end

function deepcopy_internal(d::fqPolyRepFieldElem, dict::IdDict)
Expand Down

0 comments on commit a6b9f1f

Please sign in to comment.