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

Fix minor triangulation bug #2640

Merged
merged 6 commits into from
Aug 8, 2023
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
4 changes: 2 additions & 2 deletions experimental/FTheoryTools/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Test
using Oscar
#= set_verbosity_level(:FTheoryConstructorInformation, -1)
set_verbosity_level(:FTheoryConstructorInformation, -1)
include("weierstrass.jl")
include("tate.jl") =#
include("tate.jl")
Original file line number Diff line number Diff line change
Expand Up @@ -616,19 +616,15 @@ function normal_toric_variety_from_glsm(charges::ZZMatrix; set_attributes::Bool
map = hom(G1, G2, transpose(charges))
ker = kernel(map)
embedding = snf(ker[1])[2] * ker[2]
rays = transpose(embedding.map)
integral_rays = transpose(embedding.map)

# identify the points to be triangulated
pts = zeros(ZZ, nrows(rays), ncols(charges)-nrows(charges))
for i in 1:nrows(rays)
pts[i, :] = [ZZRingElem(c) for c in rays[i, :]]
end
zero = [0 for i in 1:ncols(charges)-nrows(charges)]
pts = vcat(matrix(ZZ, transpose(zero)), matrix(ZZ, pts))
pts = matrix(ZZ, zeros(nrows(integral_rays)+1, ncols(integral_rays)))
pts[2:end, :] = integral_rays

# construct varieties
integral_rays = vcat([pts[k,:] for k in 2:nrows(pts)])
max_cones = IncidenceMatrix([[c[i]-1 for i in 2:length(c)] for c in _find_full_star_triangulation(pts)])
triang = _find_full_star_triangulation(pts)
max_cones = IncidenceMatrix([[c[i]-1 for i in 2:length(c)] for c in triang])
variety = normal_toric_variety(integral_rays, max_cones; non_redundant = true)

# set the attributes and return the variety
Expand Down
15 changes: 9 additions & 6 deletions src/PolyhedralGeometry/triangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,21 @@ function _is_full_triangulation(sop::SubdivisionOfPoints{QQFieldElem})
return true
end

_is_star_triangulation(sop::SubdivisionOfPoints{QQFieldElem}) = all(cell -> 1 in cell, maximal_cells(sop))


function _find_full_star_triangulation(pts::ZZMatrix)

function _find_full_star_triangulation(pts::ZZMatrix; seed::Int=-1)
seed == -1 || Random.seed!(seed)
n = nrows(pts)
wts = rand(0:100000, n)
# Weight of first points is lowest
wts[1] = -1
wts[1] = -1000000
sop = subdivision_of_points(pts, wts)
while !_is_full_triangulation(sop)
wts = rand(0:100000, n)
wts[1] = -1
sop = subdivision_of_points(pts, wts)
while !(_is_full_triangulation(sop) && _is_star_triangulation(sop))
wts = rand(0:100000, n)
wts[1] = -1000000
sop = subdivision_of_points(pts, wts)
end
return collect(maximal_cells(sop))
end
Expand Down
1 change: 1 addition & 0 deletions test/PolyhedralGeometry/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ include("timing.jl")
include("solve_integrally.jl")
include("lineality.jl")
include("scalar_types.jl")
include("triangulations.jl")
18 changes: 18 additions & 0 deletions test/PolyhedralGeometry/triangulations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@testset "Triangulations" begin
@testset "FTheory" begin
pts = matrix(ZZ, [0 0 0 0; -3 -4 -8 2; 0 0 1 -1; 1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1])
triang = Oscar._find_full_star_triangulation(pts; seed=994)
sop = subdivision_of_points(pts, triang)
@test Oscar._is_full_triangulation(sop)
@test Oscar._is_star_triangulation(sop)
end

@testset "Square" begin
pts = matrix(ZZ,[0 0; 1000 0; 0 1000; 501 501])
pts = 1000000000*pts
triang = Oscar._find_full_star_triangulation(pts; seed=47235)
sop = subdivision_of_points(pts, triang)
@test Oscar._is_full_triangulation(sop)
@test Oscar._is_star_triangulation(sop)
end
end
Loading