Skip to content

Commit 0220868

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

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/operators.jl

+7
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ 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(-), p::AbstractTermLike) = error("not implemented yet")
268+
269+
function MA.operate!(::typeof(-), p::_APL)
270+
negate!! = x -> MA.operate!!(-, x)
271+
map_coefficients!(negate!!, p, nonzero = true)
272+
end
273+
267274
# `MA.operate(-, p)` redirects to `-p` as it assumes that `-p` can be modified
268275
# through the MA API without modifying `p`. We should either copy the monomial
269276
# here or implement a `MA.operate(-, p)` that copies it. We choose the first

0 commit comments

Comments
 (0)