diff --git a/src/HeckeMoreStuff.jl b/src/HeckeMoreStuff.jl index 202a9c670..5dceb8ca9 100644 --- a/src/HeckeMoreStuff.jl +++ b/src/HeckeMoreStuff.jl @@ -695,12 +695,6 @@ function ^(a::ResElem, f::ZZRingElem) return b end -function set!(z::fqPolyRepFieldElem, x::fqPolyRepFieldElem) - ccall((:fq_nmod_set, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, parent(z)) -end - characteristic(F::EuclideanRingResidueField{ZZRingElem}) = abs(F.modulus) #@doc raw""" diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index c252f32e2..edeced79c 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -2275,6 +2275,7 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem d = new() ccall((:fq_nmod_init2, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + d.parent = ctx finalizer(_fq_nmod_clear_fn, d) return d end @@ -2283,9 +2284,9 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem d = new() ccall((:fq_nmod_init2, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + d.parent = ctx finalizer(_fq_nmod_clear_fn, d) - ccall((:fq_nmod_set_si, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), d, x, ctx) + set!(d, x) return d end @@ -2293,9 +2294,9 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem d = new() ccall((:fq_nmod_init2, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + d.parent = ctx finalizer(_fq_nmod_clear_fn, d) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), d, x, ctx) + set!(d, x) return d end @@ -2303,9 +2304,9 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem d = new() ccall((:fq_nmod_init2, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + d.parent = ctx finalizer(_fq_nmod_clear_fn, d) - ccall((:fq_nmod_set, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, x, ctx) + set!(d, x) return d end @@ -2313,10 +2314,9 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem d = new() ccall((:fq_nmod_init2, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + d.parent = ctx finalizer(_fq_nmod_clear_fn, d) - ccall((:fq_nmod_set_nmod_poly, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fpPolyRingElem}, Ref{fqPolyRepField}), - d, x, ctx) + set!(d, x) return d end end diff --git a/src/flint/fq_nmod.jl b/src/flint/fq_nmod.jl index 5b96ab964..5f342f61d 100644 --- a/src/flint/fq_nmod.jl +++ b/src/flint/fq_nmod.jl @@ -116,7 +116,6 @@ end function deepcopy_internal(d::fqPolyRepFieldElem, dict::IdDict) z = fqPolyRepFieldElem(parent(d), d) - z.parent = parent(d) return z end @@ -460,6 +459,36 @@ end # ############################################################################### +function set!(z::fqPolyRepFieldElem, x::fqPolyRepFieldElem) + ccall((:fq_nmod_set, libflint), Nothing, + (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), + z, x, parent(z)) +end + +function set!(z::fqPolyRepFieldElem, x::ZZRingElem) + ccall((:fq_nmod_set_fmpz, libflint), Nothing, + (Ref{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), + z, x, parent(z)) +end + +function set!(z::fqPolyRepFieldElem, x::Int) + ccall((:fq_nmod_set_si, libflint), Nothing, + (Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), + z, x, parent(z)) +end + +function set!(z::fqPolyRepFieldElem, x::UInt) + ccall((:fq_nmod_set_ui, libflint), Nothing, + (Ref{fqPolyRepFieldElem}, UInt, Ref{fqPolyRepField}), + z, x, parent(z)) +end + +function set!(z::fqPolyRepFieldElem, x::fpPolyRingElem) + ccall((:fq_nmod_set_nmod_poly, libflint), Nothing, + (Ref{fqPolyRepFieldElem}, Ref{fpPolyRingElem}, Ref{fqPolyRepField}), + z, x, parent(z)) +end + function zero!(z::fqPolyRepFieldElem) ccall((:fq_nmod_zero, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, z.parent) @@ -633,7 +662,6 @@ promote_rule(::Type{fqPolyRepFieldElem}, ::Type{fpFieldElem}) = fqPolyRepFieldEl function (a::fqPolyRepField)() z = fqPolyRepFieldElem(a) - z.parent = a return z end @@ -641,13 +669,11 @@ end function (a::fqPolyRepField)(b::Int) z = fqPolyRepFieldElem(a, b) - z.parent = a return z end function (a::fqPolyRepField)(b::ZZRingElem) z = fqPolyRepFieldElem(a, b) - z.parent = a return z end @@ -674,7 +700,6 @@ function (a::fqPolyRepField)(b::Vector{<:IntegerUnion}) da == db || error("Coercion impossible") F = Native.GF(Int(characteristic(a)), cached = false) z = fqPolyRepFieldElem(a, polynomial(F, b)) - z.parent = a return z end