Skip to content

Commit

Permalink
implement MA negation of a polynomial
Browse files Browse the repository at this point in the history
  • Loading branch information
nsajko committed Nov 26, 2023
1 parent fcb1b29 commit 0220868
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ end
Base.isapprox(p::_APL, α; kwargs...) = isapprox(promote(p, α)...; kwargs...)
Base.isapprox(α, p::_APL; kwargs...) = isapprox(promote(p, α)...; kwargs...)

MA.operate!(::typeof(-), p::AbstractTermLike) = error("not implemented yet")

function MA.operate!(::typeof(-), p::_APL)
negate!! = x -> MA.operate!!(-, x)
map_coefficients!(negate!!, p, nonzero = true)
end

# `MA.operate(-, p)` redirects to `-p` as it assumes that `-p` can be modified
# through the MA API without modifying `p`. We should either copy the monomial
# here or implement a `MA.operate(-, p)` that copies it. We choose the first
Expand Down

0 comments on commit 0220868

Please sign in to comment.