Skip to content

Commit f2921e9

Browse files
committed
Implement mutable removeleadingterm
1 parent 0b64f16 commit f2921e9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/monovec.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ end
4545
Base.getindex(x::MonomialVector, i::Integer) = Monomial(x.vars, x.Z[i])
4646
Base.getindex(x::MonomialVector, i::CartesianIndex{1}) = x[i.I[1]]
4747

48+
function Base.deleteat!(x::MonomialVector, i)
49+
deleteat!(x.Z, i)
50+
return x
51+
end
52+
4853
Base.firstindex(x::MonomialVector) = firstindex(x.Z)
4954
Base.lastindex(x::MonomialVector) = lastindex(x.Z)
5055
Base.size(x::MonomialVector) = (length(x),)

src/poly.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ MP.leadingterm(p::Polynomial) = iszero(p) ? zeroterm(p) : first(terms(p))
121121
function MP.removeleadingterm(p::Polynomial)
122122
Polynomial(p.a[2:end], p.x[2:end])
123123
end
124+
function MA.mutable_operate!(::typeof(MP.removeleadingterm), p::Polynomial)
125+
deleteat!(p.a, 1)
126+
deleteat!(p.x, 1)
127+
return p
128+
end
124129
function MP.removemonomials(p::Polynomial, x::MonomialVector)
125130
# use the fact that monomials are sorted to do this O(n) instead of O(n^2)
126131
j = 1

0 commit comments

Comments
 (0)