diff --git a/src/arb/ArbTypes.jl b/src/arb/ArbTypes.jl index 6a078ed14..47b23490d 100644 --- a/src/arb/ArbTypes.jl +++ b/src/arb/ArbTypes.jl @@ -467,16 +467,14 @@ mutable struct RealPolyRingElem <: PolyRingElem{RealFieldElem} function RealPolyRingElem(x::RealFieldElem, p::Int) z = RealPolyRingElem() - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, 0, x) + setcoeff!(z, 0, x) return z end function RealPolyRingElem(x::Vector{RealFieldElem}, p::Int) z = RealPolyRingElem() - for i = 1:length(x) - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, i - 1, x[i]) + for i in 1:length(x) + setcoeff!(z, i - 1, x[i]) end return z end @@ -549,16 +547,14 @@ mutable struct ArbPolyRingElem <: PolyRingElem{ArbFieldElem} function ArbPolyRingElem(x::ArbFieldElem, p::Int) z = ArbPolyRingElem() - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Ref{ArbFieldElem}), z, 0, x) + setcoeff!(z, 0, x) return z end function ArbPolyRingElem(x::Vector{ArbFieldElem}, p::Int) z = ArbPolyRingElem() - for i = 1:length(x) - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Ref{ArbFieldElem}), z, i - 1, x[i]) + for i in 1:length(x) + setcoeff!(z, i - 1, x[i]) end return z end @@ -636,16 +632,14 @@ mutable struct ComplexPolyRingElem <: PolyRingElem{ComplexFieldElem} function ComplexPolyRingElem(x::ComplexFieldElem, p::Int) z = ComplexPolyRingElem() - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, 0, x) + setcoeff!(z, 0, x) return z end function ComplexPolyRingElem(x::Vector{ComplexFieldElem}, p::Int) z = ComplexPolyRingElem() - for i = 1:length(x) - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, i - 1, x[i]) + for i in 1:length(x) + setcoeff!(z, i - 1, x[i]) end return z end @@ -727,16 +721,14 @@ mutable struct AcbPolyRingElem <: PolyRingElem{AcbFieldElem} function AcbPolyRingElem(x::AcbFieldElem, p::Int) z = AcbPolyRingElem() - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Ref{AcbFieldElem}), z, 0, x) + setcoeff!(z, 0, x) return z end function AcbPolyRingElem(x::Vector{AcbFieldElem}, p::Int) z = AcbPolyRingElem() - for i = 1:length(x) - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Ref{AcbFieldElem}), z, i - 1, x[i]) + for i in 1:length(x) + setcoeff!(z, i - 1, x[i]) end return z end diff --git a/src/arb/ComplexPoly.jl b/src/arb/ComplexPoly.jl index 76071a8d9..b37cbebc5 100644 --- a/src/arb/ComplexPoly.jl +++ b/src/arb/ComplexPoly.jl @@ -41,8 +41,7 @@ one(a::ComplexPolyRing) = one!(a()) function gen(a::ComplexPolyRing) z = ComplexPolyRingElem() - ccall((:acb_poly_set_coeff_si, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Int), z, 1, 1) + setcoeff!(z, 1, 1) z.parent = a return z end @@ -705,18 +704,24 @@ function fit!(z::ComplexPolyRingElem, n::Int) return nothing end -function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ZZRingElem) - ccall((:acb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) - return z -end - function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ComplexFieldElem) ccall((:acb_poly_set_coeff_acb, libflint), Nothing, (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, n, x) return z end +function setcoeff!(z::ComplexPolyRingElem, n::Int, x::Int) + ccall((:acb_poly_set_coeff_si, libflint), Nothing, + (Ref{ComplexPolyRingElem}, Int, Int), z, n, x) + return z +end + +function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ZZRingElem) + return setcoeff!(z, n, base_ring(z)(x)) +end + +setcoeff!(z::ComplexPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) + # function add!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) diff --git a/src/arb/RealPoly.jl b/src/arb/RealPoly.jl index ff4cd9008..a2d5826b5 100644 --- a/src/arb/RealPoly.jl +++ b/src/arb/RealPoly.jl @@ -41,8 +41,7 @@ one(a::RealPolyRing) = one!(a()) function gen(a::RealPolyRing) z = RealPolyRingElem() - ccall((:arb_poly_set_coeff_si, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Int), z, 1, 1) + setcoeff!(z, 1, 1) z.parent = a return z end @@ -608,18 +607,24 @@ function fit!(z::RealPolyRingElem, n::Int) return nothing end -function setcoeff!(z::RealPolyRingElem, n::Int, x::ZZRingElem) - ccall((:arb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) - return z -end - function setcoeff!(z::RealPolyRingElem, n::Int, x::RealFieldElem) ccall((:arb_poly_set_coeff_arb, libflint), Nothing, (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, n, x) return z end +function setcoeff!(z::RealPolyRingElem, n::Int, x::Int) + ccall((:arb_poly_set_coeff_si, libflint), Nothing, + (Ref{RealPolyRingElem}, Int, Int), z, n, x) + return z +end + +function setcoeff!(z::RealPolyRingElem, n::Int, x::ZZRingElem) + return setcoeff!(z, n, base_ring(z)(x)) +end + +setcoeff!(z::RealPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) + # function add!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) diff --git a/src/arb/acb_poly.jl b/src/arb/acb_poly.jl index e6c26f287..cdc6bac12 100644 --- a/src/arb/acb_poly.jl +++ b/src/arb/acb_poly.jl @@ -41,8 +41,7 @@ one(a::AcbPolyRing) = one!(a()) function gen(a::AcbPolyRing) z = AcbPolyRingElem() - ccall((:acb_poly_set_coeff_si, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Int), z, 1, 1) + setcoeff!(z, 1, 1) z.parent = a return z end @@ -701,18 +700,24 @@ function fit!(z::AcbPolyRingElem, n::Int) return nothing end -function setcoeff!(z::AcbPolyRingElem, n::Int, x::ZZRingElem) - ccall((:acb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) - return z -end - function setcoeff!(z::AcbPolyRingElem, n::Int, x::AcbFieldElem) ccall((:acb_poly_set_coeff_acb, libflint), Nothing, (Ref{AcbPolyRingElem}, Int, Ref{AcbFieldElem}), z, n, x) return z end +function setcoeff!(z::AcbPolyRingElem, n::Int, x::Int) + ccall((:acb_poly_set_coeff_si, libflint), Nothing, + (Ref{AcbPolyRingElem}, Int, Int), z, n, x) + return z +end + +function setcoeff!(z::AcbPolyRingElem, n::Int, x::ZZRingElem) + return setcoeff!(z, n, base_ring(z)(x)) +end + +setcoeff!(z::AcbPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) + # function add!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::AcbPolyRingElem) diff --git a/src/arb/arb_poly.jl b/src/arb/arb_poly.jl index 32744e189..2eb1156b3 100644 --- a/src/arb/arb_poly.jl +++ b/src/arb/arb_poly.jl @@ -41,8 +41,7 @@ one(a::ArbPolyRing) = one!(a()) function gen(a::ArbPolyRing) z = ArbPolyRingElem() - ccall((:arb_poly_set_coeff_si, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Int), z, 1, 1) + setcoeff!(z, 1, 1) z.parent = a return z end @@ -608,18 +607,24 @@ function fit!(z::ArbPolyRingElem, n::Int) return nothing end -function setcoeff!(z::ArbPolyRingElem, n::Int, x::ZZRingElem) - ccall((:arb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) - return z -end - function setcoeff!(z::ArbPolyRingElem, n::Int, x::ArbFieldElem) ccall((:arb_poly_set_coeff_arb, libflint), Nothing, (Ref{ArbPolyRingElem}, Int, Ref{ArbFieldElem}), z, n, x) return z end +function setcoeff!(z::ArbPolyRingElem, n::Int, x::Int) + ccall((:arb_poly_set_coeff_si, libflint), Nothing, + (Ref{ArbPolyRingElem}, Int, Int), z, n, x) + return z +end + +function setcoeff!(z::ArbPolyRingElem, n::Int, x::ZZRingElem) + return setcoeff!(z, n, base_ring(z)(x)) +end + +setcoeff!(z::ArbPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) + # function add!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::ArbPolyRingElem)