Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promotion for ideal #47

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ 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
Expand Down
6 changes: 6 additions & 0 deletions src/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ 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)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 9 additions & 0 deletions test/macro.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module TestMacro

using Test
import MutableArithmetics as MA
using SemialgebraicSets
using MultivariatePolynomials

Expand All @@ -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()
Expand Down
Loading