Skip to content

Commit 39d5755

Browse files
committed
implement MA negation of a polynomial
1 parent fcb1b29 commit 39d5755

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/operators.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ end
264264
Base.isapprox(p::_APL, α; kwargs...) = isapprox(promote(p, α)...; kwargs...)
265265
Base.isapprox(α, p::_APL; kwargs...) = isapprox(promote(p, α)...; kwargs...)
266266

267+
MA.operate!(::typeof(-), ::AbstractTermLike) = error("not implemented yet")
268+
269+
MA.operate_to!(::AbstractTermLike, ::typeof(-), ::_APL) = error("not implemented yet")
270+
271+
function MA.operate!(::typeof(-), p::_APL)
272+
negate!! = x -> MA.operate!!(-, x)
273+
return map_coefficients!(negate!!, p, nonzero = true)
274+
end
275+
276+
function MA.operate_to!(o::P, ::typeof(-), p::P) where {P<:_APL}
277+
return map_coefficients_to!(o, -, p, nonzero = true)
278+
end
279+
267280
# `MA.operate(-, p)` redirects to `-p` as it assumes that `-p` can be modified
268281
# through the MA API without modifying `p`. We should either copy the monomial
269282
# here or implement a `MA.operate(-, p)` that copies it. We choose the first

0 commit comments

Comments
 (0)