From f443719de1b64c324929a31691c479d1ca1bdacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 25 Jul 2023 16:33:11 -0400 Subject: [PATCH] Fix in staircase dependence (#60) * Fix in staircase dependence * Fix format --- src/dependence.jl | 2 +- test/extract.jl | 7 +------ test/null.jl | 34 +++++++++++++++++++++++++++++----- test/utils.jl | 7 +++++++ 4 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 test/utils.jl diff --git a/src/dependence.jl b/src/dependence.jl index 9dcda78..f5cfd6d 100644 --- a/src/dependence.jl +++ b/src/dependence.jl @@ -161,7 +161,7 @@ function StaircaseDependence( border = shift * mono if isnothing(_monomial_index(standard, border)) && isnothing(_monomial_index(corners, border)) - i = _index(basis, mono) + i = _index(basis, border) if isnothing(i) || !is_dependent(i) push!(independent_border, border) else diff --git a/test/extract.jl b/test/extract.jl index d2f2e42..387021d 100644 --- a/test/extract.jl +++ b/test/extract.jl @@ -24,12 +24,7 @@ end Mod.@polyvar x -function testelements(X, Y, atol) - @test length(X) == length(Y) - for y in Y - @test any(x -> isapprox(x, y, atol = atol), X) - end -end +include("utils.jl") function _atoms(atoms, rank_check, solver) Mod.@polyvar x[1:2] diff --git a/test/null.jl b/test/null.jl index 84aeca2..83f56f6 100644 --- a/test/null.jl +++ b/test/null.jl @@ -7,7 +7,31 @@ import MultivariateMoments as MM b(x) = MB.MonomialBasis(x) -function test_univariate_infinity(x) +include("utils.jl") + +function test_dreesen1(x, y) + matrix = Float64[ + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + 0 0 1 0 + 1 0 0 0 + ] + basis = MB.MonomialBasis([1, y, x, y^2, x * y, x^2]) + null = MM.MacaulayNullspace(matrix, basis, 1e-8) + @testset "$D" for D in [MM.AnyDependence, MM.StaircaseDependence] + @testset "$name" for (solver, name) in [ + (MM.ShiftNullspace{D}(), "shift"), + #(MM.Echelon{D}(fallback = false), "echelon no fallback"), + #(MM.Echelon{D}(fallback = true), "echelon fallback"), + ] + @test isnothing(MM.solve(null, solver)) + end + end +end + +function _test_univariate_infinity(x, y) Z = Float64[ 1 0 2 0 @@ -51,12 +75,12 @@ using Test import DynamicPolynomials @testset "DynamicPolynomials" begin - DynamicPolynomials.@polyvar x - TestNull.runtests(x) + DynamicPolynomials.@polyvar x y + TestNull.runtests(x, y) end import TypedPolynomials @testset "TypedPolynomials" begin - TypedPolynomials.@polyvar x - TestNull.runtests(x) + TypedPolynomials.@polyvar x y + TestNull.runtests(x, y) end diff --git a/test/utils.jl b/test/utils.jl new file mode 100644 index 0000000..b2ef432 --- /dev/null +++ b/test/utils.jl @@ -0,0 +1,7 @@ +function testelements(X, Y, atol) + @test length(X) == length(Y) + for y in Y + @show y + @test any(x -> isapprox(x, y, atol = atol), X) + end +end