JuliaAlgebra / MultivariatePolynomials.jl

Multivariate polynomials interface
https://juliaalgebra.github.io/MultivariatePolynomials.jl/stable/
Other
134 stars 27 forks source link

`MA.operate!(-, term0, term1)` recurs infinitely #284

Open nsajko opened 8 months ago

nsajko commented 8 months ago
julia> using DynamicPolynomials

julia> import MutableArithmetics

julia> const MA = MutableArithmetics
MutableArithmetics

julia> @polyvar x
(x,)

julia> MA.operate!(-, 2x, 3x)
^CERROR: InterruptException:
Stacktrace:
   [1] operate!
     @ MultivariatePolynomials ~/tmp/jl/MultivariatePolynomials.jl/src/operators.jl:303 [inlined]
   [2] operate!
     @ MultivariatePolynomials ~/tmp/jl/MultivariatePolynomials.jl/src/operators.jl:97 [inlined]
   [3] operate!
     @ MultivariatePolynomials ~/tmp/jl/MultivariatePolynomials.jl/src/operators.jl:303 [inlined]
   [4] operate!(op::typeof(-), p::Term{Int64, Monomial{DynamicPolynomials.Commutative{…}, Graded{…}}}, α::Term{Term{Term{…}, Monomial{…}}, Monomial{DynamicPolynomials.Commutative{…}, Graded{…}}})
     @ MultivariatePolynomials ~/tmp/jl/MultivariatePolynomials.jl/src/operators.jl:97--- the above 4 lines are repeated 54 more times ---
Some type information was truncated. Use `show(err)` to see complete types.
nsajko commented 8 months ago

related: #167?

blegat commented 8 months ago

These might indeed be related but I think it's different. I guess operate! should mutate the coefficient if the terms have the same monomial and error otherwise. This simply need a new method