From 66dcc13f843086130d216b735161d895ccabe68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 24 May 2024 19:19:17 +0200 Subject: [PATCH 1/4] Add promotion for ideal --- src/fix.jl | 3 +++ src/variety.jl | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/fix.jl b/src/fix.jl index 10195fb..9f3ead1 100644 --- a/src/fix.jl +++ b/src/fix.jl @@ -67,6 +67,9 @@ function Base.convert( end ideal(set::FixedVariablesSet, args...) = set.ideal +function MA.promote_operation(::typeof(ideal), ::Type{FixedVariablesSet{V,T,M}}) where {V,T,M} + return FixedVariablesIdeal{V,T,M} +end MP.variables(set::FixedVariablesSet) = MP.variables(set.ideal) function MP.monomial_type(::Type{FixedVariablesSet{V,T,M}}) where {V,T,M} return M diff --git a/src/variety.jl b/src/variety.jl index 4b579cf..92a59a4 100644 --- a/src/variety.jl +++ b/src/variety.jl @@ -116,6 +116,9 @@ function projective_algebraic_set(p::Vector, args...) end ideal(V::AlgebraicSet) = V.I +function MA.promote_operation(::typeof(ideal), ::Type{<:AlgebraicSet{T,P,A}}) where {T,P,A} + return PolynomialIdeal{T,P,A} +end MP.variables(V::AlgebraicSet) = MP.variables(V.I) MP.monomial_type(::Type{<:AlgebraicSet{T,P}}) where {T,P} = MP.monomial_type(P) From 34f8fdde2ad7525867eff8fd383d15d340001048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 25 May 2024 09:17:12 +0200 Subject: [PATCH 2/4] Fix format --- src/fix.jl | 5 ++++- src/variety.jl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fix.jl b/src/fix.jl index 9f3ead1..4969a1c 100644 --- a/src/fix.jl +++ b/src/fix.jl @@ -67,7 +67,10 @@ function Base.convert( end ideal(set::FixedVariablesSet, args...) = set.ideal -function MA.promote_operation(::typeof(ideal), ::Type{FixedVariablesSet{V,T,M}}) where {V,T,M} +function MA.promote_operation( + ::typeof(ideal), + ::Type{FixedVariablesSet{V,T,M}}, +) where {V,T,M} return FixedVariablesIdeal{V,T,M} end MP.variables(set::FixedVariablesSet) = MP.variables(set.ideal) diff --git a/src/variety.jl b/src/variety.jl index 92a59a4..28e685d 100644 --- a/src/variety.jl +++ b/src/variety.jl @@ -116,7 +116,10 @@ function projective_algebraic_set(p::Vector, args...) end ideal(V::AlgebraicSet) = V.I -function MA.promote_operation(::typeof(ideal), ::Type{<:AlgebraicSet{T,P,A}}) where {T,P,A} +function MA.promote_operation( + ::typeof(ideal), + ::Type{<:AlgebraicSet{T,P,A}}, +) where {T,P,A} return PolynomialIdeal{T,P,A} end From 97cc392ce7ae759f9f0e0f295d203c016e1a1d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 25 May 2024 09:28:31 +0200 Subject: [PATCH 3/4] Add tests --- test/macro.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/macro.jl b/test/macro.jl index a4e8b9a..6080be9 100644 --- a/test/macro.jl +++ b/test/macro.jl @@ -1,6 +1,7 @@ module TestMacro using Test +import MutableArithmetics as MA using SemialgebraicSets using MultivariatePolynomials @@ -14,6 +15,14 @@ function _test_polynomial_API(set, vars) mono = prod(vars) @test @inferred(variables(set)) == variables(mono) @test @inferred(monomial_type(typeof(set))) == monomial_type(typeof(mono)) + V = set + if !(V isa AbstractAlgebraicSet) + V = algebraic_set(V) + end + if !(V isa FullSpace) + @test typeof(ideal(V)) == MA.promote_operation(ideal, typeof(V)) + end + return end function runtests() From 8eb60b20dfda0682a90796516bb1865f26e766a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 25 May 2024 09:34:31 +0200 Subject: [PATCH 4/4] Add MA to tests --- test/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Project.toml b/test/Project.toml index 5df2053..17fcc0d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3" +MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SemialgebraicSets = "8e049039-38e8-557d-ae3a-bc521ccf6204" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"