From 1afa25526ca9def9824c8815ba2c2dbb0e94da25 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Tue, 19 Aug 2025 17:31:07 +0530 Subject: [PATCH 1/4] refactor: use new `polynomial_merge!` --- src/operators.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/operators.jl b/src/operators.jl index dd27226..cbe67b7 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -183,9 +183,9 @@ end # TODO need to check that this also works for non-commutative function MA.operate!( op::Union{typeof(+),typeof(-)}, - p::Polynomial{V}, - q::Polynomial{V}, -) where {V<:Commutative} + p::Polynomial{V, M1, T1}, + q::Polynomial{V, M2, T2}, +) where {V<:Commutative, M1, M2, T1, T2} if MP.variables(p) != MP.variables(q) allvars, maps = ___add_variables!(p, q) if length(allvars) == length(MP.variables(q)) @@ -239,6 +239,7 @@ function MA.operate!( combine, keep, resize, + Tuple{MA.promote_operation(op, T1, T2), Vector{Int}}, ) return p end From 3b5113689c74148864206a556512ebb37ac2fef2 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Tue, 19 Aug 2025 17:33:02 +0530 Subject: [PATCH 2/4] test: test in-place non-concrete polynomial addition --- test/mutable_arithmetics.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/mutable_arithmetics.jl b/test/mutable_arithmetics.jl index 5529013..f5959d7 100644 --- a/test/mutable_arithmetics.jl +++ b/test/mutable_arithmetics.jl @@ -2,6 +2,7 @@ using Test import MutableArithmetics const MA = MutableArithmetics +import MultivariatePolynomials as MP using DynamicPolynomials @@ -100,3 +101,15 @@ end @test (@allocated MA.operate!(-, poly2, x)) <= 144 end end + +@testset "Non-concrete in-place polynomial addition" begin + @polyvar p q r s + p1 = MP.polynomial(r - q, Number) + MP.polynomial(3//5 * p^2, Number) + p2 = MP.polynomial(1//2 + s, Number) + MP.polynomial(p^2, Number) + result = p1 + p2 + @test isequal(result, MA.operate!(+, p1, p2)) + + p1 = MP.polynomial(r - q, Number) + MP.polynomial(3//5 * p^2, Number) + p2 = MP.polynomial(1//2 + s, Number) + MP.polynomial(p^2, Number) + @test isequal(result, MA.operate!(+, p2, p1)) +end From 2d37a81e306e58578a5c7bd44450e6045d8f8349 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 17 Sep 2025 17:17:09 +0530 Subject: [PATCH 3/4] build: bump MutableArithmetics compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index decd4e0..564d4e0 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] MultivariatePolynomials = "0.5.9" -MutableArithmetics = "1" +MutableArithmetics = "1.6.5" Reexport = "1" julia = "1" From 8d9666116a49e6e720a0c82869c90c28a920cd2f Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Thu, 18 Sep 2025 10:38:45 +0530 Subject: [PATCH 4/4] build: bump MultivariatePolynomials compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 564d4e0..8889cef 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -MultivariatePolynomials = "0.5.9" +MultivariatePolynomials = "0.5.12" MutableArithmetics = "1.6.5" Reexport = "1" julia = "1"