diff --git a/src/flat.jl b/src/flat.jl index af405a4..4390d06 100644 --- a/src/flat.jl +++ b/src/flat.jl @@ -6,9 +6,13 @@ end SemialgebraicSets.is_zero_dimensional(::ZeroDimensionalVariety) = true Base.length(v::ZeroDimensionalVariety) = length(v.elements) Base.iterate(v::ZeroDimensionalVariety, args...) = iterate(v.elements, args...) -function Base.show(io::IO, V::ZeroDimensionalVariety) +function Base.show(io::IO, ::MIME"text/plain", V::ZeroDimensionalVariety) println(io, "ZeroDimensionalVariety with elements:") - return show(io, V.elements) + show(io, V.elements) + return +end +function Base.show(io::IO, V::ZeroDimensionalVariety) + return show(io, MIME"text/plain"(), V) end # Decomposition of the pencil of matrices diff --git a/src/null.jl b/src/null.jl index ac4e684..a76faf8 100644 --- a/src/null.jl +++ b/src/null.jl @@ -32,6 +32,17 @@ function Base.getindex( ) end +function MacaulayNullspace( + ν::MomentMatrix, + rank_check::RankCheck, + ldlt::LowRankLDLTAlgorithm = SVDLDLT(), +) + M = value_matrix(ν) + chol = low_rank_ldlt(M, ldlt, rank_check) + @assert size(chol.L, 1) == LinearAlgebra.checksquare(M) + return MacaulayNullspace(chol.L, ν.basis, accuracy(chol)) +end + abstract type MacaulayNullspaceSolver end function solve(null::MacaulayNullspace, solver::MacaulayNullspaceSolver) @@ -58,11 +69,8 @@ function compute_support!( rank_check::RankCheck, solver::ImageSpaceSolver, ) - M = value_matrix(ν) - chol = low_rank_ldlt(M, solver.ldlt, rank_check) - @assert size(chol.L, 1) == LinearAlgebra.checksquare(M) ν.support = - solve(MacaulayNullspace(chol.L, ν.basis, accuracy(chol)), solver.null) + solve(MacaulayNullspace(ν, rank_check, solver.ldlt), solver.null) return end diff --git a/test/commutativetests.jl b/test/commutativetests.jl index 47a6b9b..42c459a 100644 --- a/test/commutativetests.jl +++ b/test/commutativetests.jl @@ -2,6 +2,7 @@ include("moment_vector.jl") include("expectation.jl") include("moment_matrix.jl") include("rank.jl") +include("flat.jl") include("extract.jl") include("atomic.jl") include("hermitian_poly.jl") diff --git a/test/flat.jl b/test/flat.jl new file mode 100644 index 0000000..aa84ae8 --- /dev/null +++ b/test/flat.jl @@ -0,0 +1,8 @@ +using Test, MultivariateMoments + +@testset "ZeroDimensionalVariety" begin + V = ZeroDimensionalVariety([[1], [2]]) + expected = "ZeroDimensionalVariety with elements:\n[[1], [2]]" + @test sprint(show, V) == expected + @test sprint(show, MIME"text/plain"(), V) == expected +end