Skip to content

Commit e441b40

Browse files
authored
Add promotion for ideal (#47)
* Add promotion for ideal * Fix format * Add tests * Add MA to tests
1 parent ff8a74f commit e441b40

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

src/fix.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function Base.convert(
6767
end
6868

6969
ideal(set::FixedVariablesSet, args...) = set.ideal
70+
function MA.promote_operation(
71+
::typeof(ideal),
72+
::Type{FixedVariablesSet{V,T,M}},
73+
) where {V,T,M}
74+
return FixedVariablesIdeal{V,T,M}
75+
end
7076
MP.variables(set::FixedVariablesSet) = MP.variables(set.ideal)
7177
function MP.monomial_type(::Type{FixedVariablesSet{V,T,M}}) where {V,T,M}
7278
return M

src/variety.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ function projective_algebraic_set(p::Vector, args...)
116116
end
117117

118118
ideal(V::AlgebraicSet) = V.I
119+
function MA.promote_operation(
120+
::typeof(ideal),
121+
::Type{<:AlgebraicSet{T,P,A}},
122+
) where {T,P,A}
123+
return PolynomialIdeal{T,P,A}
124+
end
119125

120126
MP.variables(V::AlgebraicSet) = MP.variables(V.I)
121127
MP.monomial_type(::Type{<:AlgebraicSet{T,P}}) where {T,P} = MP.monomial_type(P)

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07"
33
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
44
MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
5+
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
56
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
67
SemialgebraicSets = "8e049039-38e8-557d-ae3a-bc521ccf6204"
78
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/macro.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module TestMacro
22

33
using Test
4+
import MutableArithmetics as MA
45
using SemialgebraicSets
56
using MultivariatePolynomials
67

@@ -14,6 +15,14 @@ function _test_polynomial_API(set, vars)
1415
mono = prod(vars)
1516
@test @inferred(variables(set)) == variables(mono)
1617
@test @inferred(monomial_type(typeof(set))) == monomial_type(typeof(mono))
18+
V = set
19+
if !(V isa AbstractAlgebraicSet)
20+
V = algebraic_set(V)
21+
end
22+
if !(V isa FullSpace)
23+
@test typeof(ideal(V)) == MA.promote_operation(ideal, typeof(V))
24+
end
25+
return
1726
end
1827

1928
function runtests()

0 commit comments

Comments
 (0)