@@ -385,46 +385,74 @@ end
385385
386386# Iterators
387387
388- struct MPolyCoeffs{T <: AbstractAlgebra.NCRingElem , S <: AbstractAlgebra.RingElement }
388+ mutable struct MPolyCoeffs{T <: AbstractAlgebra.NCRingElem , S <: AbstractAlgebra.RingElement }
389389 poly:: T
390390 inplace:: Bool
391391 temp:: S # only used if inplace == true
392- end
393392
394- function MPolyCoeffs (f:: AbstractAlgebra.NCRingElem )
395- return MPolyCoeffs (f, false , zero (coefficient_ring (parent (f))))
393+ function MPolyCoeffs (f:: AbstractAlgebra.NCRingElem )
394+ I = new {typeof(f), elem_type(coefficient_ring_type(f))} ()
395+ I. poly = f
396+ I. inplace = false
397+ return I
398+ end
399+
400+ function MPolyCoeffs (f:: AbstractAlgebra.NCRingElem , inplace:: Bool , temp:: AbstractAlgebra.RingElement )
401+ return new {typeof(f), typeof(temp)} (f, inplace, temp)
402+ end
396403end
397404
398405# S may be the type of anything that can store an exponent vector, for example
399406# Vector{Int}, ZZMatrix, ...
400- struct MPolyExponentVectors{T <: AbstractAlgebra.RingElem , S}
407+ mutable struct MPolyExponentVectors{T <: AbstractAlgebra.RingElem , S}
401408 poly:: T
402409 inplace:: Bool
403410 temp:: S # only used if inplace == true
404- end
405411
406- function MPolyExponentVectors (f:: AbstractAlgebra.RingElem )
407- return MPolyExponentVectors (f, false , Vector {Int} ())
412+ function MPolyExponentVectors (:: Type{S} , f:: AbstractAlgebra.NCRingElem ) where S
413+ I = new {typeof(f), S} ()
414+ I. poly = f
415+ I. inplace = false
416+ return I
417+ end
418+
419+ function MPolyExponentVectors (f:: AbstractAlgebra.NCRingElem , inplace:: Bool , temp:: S ) where S
420+ return new {typeof(f), S} (f, inplace, temp)
421+ end
408422end
409423
410- struct MPolyTerms{T <: AbstractAlgebra.NCRingElem }
424+ mutable struct MPolyTerms{T <: AbstractAlgebra.NCRingElem }
411425 poly:: T
412426 inplace:: Bool
413427 temp:: T # only used if inplace == true
414- end
415428
416- function MPolyTerms (f:: AbstractAlgebra.NCRingElem )
417- return MPolyTerms (f, false , zero (parent (f)))
429+ function MPolyTerms (f:: AbstractAlgebra.NCRingElem )
430+ I = new {typeof(f)} ()
431+ I. poly = f
432+ I. inplace = false
433+ return I
434+ end
435+
436+ function MPolyTerms (f:: T , inplace:: Bool , temp:: T ) where {T <: AbstractAlgebra.NCRingElem }
437+ return new {T} (f, inplace, temp)
438+ end
418439end
419440
420- struct MPolyMonomials{T <: AbstractAlgebra.NCRingElem }
441+ mutable struct MPolyMonomials{T <: AbstractAlgebra.NCRingElem }
421442 poly:: T
422443 inplace:: Bool
423444 temp:: T # only used if inplace == true
424- end
425445
426- function MPolyMonomials (f:: NCRingElem )
427- return MPolyMonomials (f, false , zero (parent (f)))
446+ function MPolyMonomials (f:: AbstractAlgebra.NCRingElem )
447+ I = new {typeof(f)} ()
448+ I. poly = f
449+ I. inplace = false
450+ return I
451+ end
452+
453+ function MPolyMonomials (f:: T , inplace:: Bool , temp:: T ) where {T <: AbstractAlgebra.NCRingElem }
454+ return new {T} (f, inplace, temp)
455+ end
428456end
429457
430458mutable struct MPolyBuildCtx{T, S}
0 commit comments