Skip to content

Commit

Permalink
Fix and use setcoeff! for RealPolyRingElem
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 23, 2024
1 parent 5b0fea5 commit 451d06b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/arb/ArbTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,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
Expand Down
21 changes: 13 additions & 8 deletions src/arb/RealPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ one(a::RealPolyRing) = a(1)

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
Expand Down Expand Up @@ -618,18 +617,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))

Check warning on line 633 in src/arb/RealPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/RealPoly.jl#L632-L633

Added lines #L632 - L633 were not covered by tests
end

setcoeff!(z::RealPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x))

Check warning on line 636 in src/arb/RealPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/RealPoly.jl#L636

Added line #L636 was not covered by tests

function mul!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem)
ccall((:arb_poly_mul, libflint), Nothing,
(Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int),
Expand Down

0 comments on commit 451d06b

Please sign in to comment.