@@ -369,12 +369,15 @@ julia> collect(ExponentsIterator(ntuple(zero, 3), mindegree = 2, maxdegree = 2))
369369```
370370You can also change the monomial ordering as follows:
371371```jldoctest
372- julia> collect(Iterators.take( ExponentsIterator{LexOrder}(zeros(Int, 2), mindegree = 2, maxdegree = 4), 4 ))
373- 4 -element Vector{Vector{Int64}}:
372+ julia> collect(ExponentsIterator{LexOrder}(zeros(Int, 2), mindegree = 2, maxdegree = 3 ))
373+ 7 -element Vector{Vector{Int64}}:
374374 [0, 2]
375375 [0, 3]
376- [0, 4]
377- [1, 0]
376+ [1, 1]
377+ [1, 2]
378+ [2, 0]
379+ [2, 1]
380+ [3, 0]
378381```
379382"""
380383struct ExponentsIterator{M,D<: Union{Nothing,Int} ,O}
@@ -416,7 +419,7 @@ _increase_degree(it::ExponentsIterator{M,Int}, deg) where {M} = deg < it.maxdegr
416419_adjust_degree (:: ExponentsIterator{<:Graded} , _, Δ) = Δ
417420# Otherwise, we just need the degree to stay above `it.mindegree`,
418421# so we need to add `it.mindegree - deg`
419- _adjust_degree (it:: ExponentsIterator , deg, _) = min (0 , it. mindegree - deg)
422+ _adjust_degree (it:: ExponentsIterator , deg, _) = max (0 , it. mindegree - deg)
420423
421424_setindex! (x, v, i) = Base. setindex! (x, v, i)
422425_setindex! (x:: Tuple , v, i) = Base. setindex (x, v, i)
@@ -449,10 +452,12 @@ function _iterate!(it::ExponentsIterator{M}, z, deg) where {M}
449452 j = I[i]
450453 Δ = z[j] - 1
451454 z = _setindex! (z, 0 , j)
455+ j = I[i]
452456 deg -= Δ
453457 Δ = _adjust_degree (it, deg, Δ)
454458 deg += Δ
455459 z = _setindex! (z, Δ, _last_lex_index (nvariables (it), M))
460+ j = I[i]
456461 z = _increment! (z, _prev_lex_index (j, M))
457462 return z, deg
458463end
0 commit comments