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

Build Nullspace from MomentMatrix #84

Merged
merged 6 commits into from
Jul 2, 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
8 changes: 6 additions & 2 deletions src/flat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions src/null.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/commutativetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions test/flat.jl
Original file line number Diff line number Diff line change
@@ -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
Loading