Skip to content

Commit 501d7a7

Browse files
committed
Towards inplace iterators for exponents of multivariate polynomials etc.
1 parent 2a1d29b commit 501d7a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/flint/fmpq_mpoly.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ end
108108

109109
function coeff(a::QQMPolyRingElem, i::Int)
110110
z = QQFieldElem()
111+
return coeff!(z, a, i)
112+
end
113+
114+
function coeff!(z::QQFieldElem, a::QQMPolyRingElem, i::Int)
111115
n = length(a)
112116
(i < 1 || i > n) && error("Index must be between 1 and $(length(a))")
113117
@ccall libflint.fmpq_mpoly_get_term_coeff_fmpq(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing
@@ -911,6 +915,10 @@ end
911915
# Return the i-th term of the polynomial, as a polynomial
912916
function term(a::QQMPolyRingElem, i::Int)
913917
z = parent(a)()
918+
return term!(z, a, i)
919+
end
920+
921+
function term!(z::QQMPolyRingElem, a::QQMPolyRingElem, i::Int)
914922
n = length(a)
915923
(i < 1 || i > n) && error("Index must be between 1 and $(length(a))")
916924
@ccall libflint.fmpq_mpoly_get_term(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing

0 commit comments

Comments
 (0)