Skip to content

Commit

Permalink
Merge pull request oscar-system#2560 from oscar-system/lk/toric/polyh…
Browse files Browse the repository at this point in the history
…edral_fan
  • Loading branch information
lkastner authored Jul 14, 2023
2 parents 31d921e + 7ff4f8c commit 3b64d46
Show file tree
Hide file tree
Showing 25 changed files with 668 additions and 796 deletions.
11 changes: 6 additions & 5 deletions src/AlgebraicGeometry/ToricVarieties/JToric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,28 @@ function push_attribute_if_exists!(result::Vector{String},
end

include("NormalToricVarieties/constructors.jl")
include("NormalToricVarieties/auxiliary.jl")
include("NormalToricVarieties/toric_ideal.jl")
include("NormalToricVarieties/properties.jl")
include("NormalToricVarieties/attributes.jl")
include("NormalToricVarieties/methods.jl")
include("NormalToricVarieties/betti_numbers.jl")
include("NormalToricVarieties/standard_constructions.jl")

include("CyclicQuotientSingularities/CyclicQuotientSingularities.jl")

include("ToricDivisors/constructors.jl")
include("ToricDivisors/properties.jl")
include("ToricDivisors/attributes.jl")
include("ToricDivisors/special_attributes.jl")
include("ToricDivisors/standard_constructions.jl")

include("ToricDivisorClasses/constructors.jl")
include("ToricDivisorClasses/properties.jl")
include("ToricDivisorClasses/attributes.jl")
include("ToricDivisorClasses/special_attributes.jl")
include("ToricDivisorClasses/standard_constructions.jl")

include("ToricLineBundles/constructors.jl")
include("ToricLineBundles/properties.jl")
include("ToricLineBundles/attributes.jl")
include("ToricLineBundles/special_attributes.jl")
include("ToricLineBundles/standard_constructions.jl")

include("CohomologyClasses/constructors.jl")
include("CohomologyClasses/properties.jl")
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

80 changes: 18 additions & 62 deletions src/PolyhedralGeometry/triangulations.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
using JSON
using TOPCOM_jll

function _postprocess_polymake_triangs(triangs::Polymake.Array{Polymake.Set{Polymake.Set{Polymake.to_cxx_type(Int)}}})
result = Vector{Vector{Int}}[]
for triang in triangs
push!(result, [Polymake.to_one_based_indexing(Vector{Int}(t)) for t in triang])
end
return result
end

function topcom_regular_triangulations(pts::AbstractCollection[PointVector]; full::Bool=false)
input = homogenized_matrix(pts, 1)
inputstr = join(["["*join(input[i,:], ",")*"]" for i in 1:nrows(input)],",\n")
in = Pipe()
out = Pipe()
err = Pipe()
Base.link_pipe!(in, writer_supports_async=true)
Base.link_pipe!(out, reader_supports_async=true)
Base.link_pipe!(err, reader_supports_async=true)
cmd = Oscar.TOPCOM_jll.points2triangs()
if full
cmd = Oscar.TOPCOM_jll.points2finetriangs()
end
proc = run(pipeline(`$(cmd) --regular`, stdin=in, stdout=out, stderr=err), wait=false)
task = @async begin
write(in, "[\n$inputstr\n]\n")
close(in)
end
close(in.out)
close(out.in)
close(err.in)
result = Vector{Vector{Vector{Int}}}()
for line in eachline(out)
m = match(r"{{.*}}", line)
triang = replace(m.match, "{"=>"[")
triang = replace(triang, "}"=>"]")
triang = convert(Vector{Vector{Int}},JSON.parse(triang))
push!(result, Polymake.to_one_based_indexing(triang))
end
wait(task)
if !success(proc)
msg = eof(err) ? "unknown error" : readchomp(err)
error("Failed to run TOPCOM: $msg")
end
return result
input = homogenized_matrix(pts, 1)
PC = Polymake.polytope.PointConfiguration(POINTS=input)
result = full ? Polymake.polytope.topcom_fine_and_regular_triangulations(PC) : Polymake.polytope.topcom_regular_triangulations(PC)
return _postprocess_polymake_triangs(result)
end

function topcom_regular_triangulation(pts::AbstractCollection[PointVector]; full::Bool=false)
Expand All @@ -47,11 +25,9 @@ function topcom_regular_triangulation(pts::AbstractCollection[PointVector]; full
Base.link_pipe!(in, writer_supports_async=true)
Base.link_pipe!(out, reader_supports_async=true)
Base.link_pipe!(err, reader_supports_async=true)
cmd = Oscar.TOPCOM_jll.points2triangs()
cmd = Oscar.TOPCOM_jll.points2placingtriang()
if full
cmd = Oscar.TOPCOM_jll.points2finetriang()
else
cmd = Oscar.TOPCOM_jll.points2placingtriang()
end
proc = run(pipeline(`$(cmd) --regular`, stdin=in, stdout=out, stderr=err), wait=false)
task = @async begin
Expand All @@ -77,26 +53,7 @@ function topcom_regular_triangulation(pts::AbstractCollection[PointVector]; full
return result
end

################################################################################
# TODO: Remove the following two functions after next polymake release 4.7
function _is_full_triangulation(triang::Vector{Vector{Int}}, npoints::Int)
u = Set{Int}()
for v in triang
union!(u, v)
if length(u) == npoints
return true
end
end
return false
end

function _postprocess(triangs::Vector{Vector{Vector{Int}}}, npoints::Int, full::Bool)
result = Polymake.to_one_based_indexing(triangs)
if full
result = [t for t in result if _is_full_triangulation(t, npoints)]
end
return result
end
################################################################################

function _is_star_triangulation(triang::Vector{Vector{Int}})
Expand Down Expand Up @@ -144,9 +101,8 @@ function all_triangulations(pts::AbstractCollection[PointVector]; full::Bool=fal
input = homogenized_matrix(pts, 1)
PC = Polymake.polytope.PointConfiguration(POINTS=input)
PC.FULL_DIM::Bool || error("Input points must have full rank.")
triangs = Polymake.polytope.topcom_all_triangulations(PC)
result = [[[e for e in simplex] for simplex in triang] for triang in triangs]
return _postprocess(result, nrows(input), full)
result = full ? Polymake.polytope.topcom_fine_triangulations(PC) : Polymake.polytope.topcom_all_triangulations(PC)
return _postprocess_polymake_triangs(result)
end


Expand Down Expand Up @@ -233,7 +189,7 @@ julia> star_triangulations(hex; full=true)
([0 0; -1 -1; 0 -1; 1 0; 1 1; 0 1; -1 0], [[[1, 2, 3], [1, 2, 7], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7]]])
julia> star_triangulations(hex; full=true, regular=true)
([0 0; -1 -1; 0 -1; 1 0; 1 1; 0 1; -1 0], [[[1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 2, 7]]])
([0 0; -1 -1; 0 -1; 1 0; 1 1; 0 1; -1 0], [[[1, 2, 3], [1, 2, 7], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7]]])
```
A three-dimensional example with two star triangulations.
```jldoctest
Expand Down Expand Up @@ -290,7 +246,7 @@ julia> V = vertices(c)
julia> regular_triangulations(V)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 3, 4], [1, 2, 4]]
[[1, 2, 4], [1, 3, 4]]
```
"""
function regular_triangulations(pts::AbstractCollection[PointVector]; full::Bool=false)
Expand Down Expand Up @@ -326,7 +282,7 @@ Polyhedron in ambient dimension 2
julia> regular_triangulations(c)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 3, 4], [1, 2, 4]]
[[1, 2, 4], [1, 3, 4]]
```
"""
function regular_triangulations(P::Polyhedron)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Affine normal toric varieties (set_attributes = $set_attributes)" for set_attributes in [true, false]

antv = affine_normal_toric_variety(Oscar.positive_hull([1 1; -1 1]); set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/algebraic_cycles.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Algebraic cycles (set_attributes = $set_attributes)" for set_attributes in [true, false]

antv = affine_normal_toric_variety(Oscar.positive_hull([1 1; -1 1]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Cyclic Quotient Singularities" begin

cyc = cyclic_quotient_singularity(2, 1)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/del_pezzo_surfaces.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "del Pezzo surfaces (set_attributes = $set_attributes)" for set_attributes in [true, false]

dP0 = del_pezzo_surface(NormalToricVariety, 0; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/direct_products.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Direct products" begin

F5 = normal_toric_variety([[1, 0], [0, 1], [-1, 5], [0, -1]], [[1, 2], [2, 3], [3, 4], [4, 1]])
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/hirzebruch_surfaces.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Hirzebruch surfaces (set_attributes = $set_attributes)" for set_attributes in [true, false]

F0 = hirzebruch_surface(NormalToricVariety, 0; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/intersection_numbers.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Topological intersection numbers (set_attributes = $set_attributes)" for set_attributes in [true, false]

antv = affine_normal_toric_variety(Oscar.positive_hull([1 1; -1 1]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Line bundle cohomologies and vanishing sets (set_attributes = $set_attributes)" for set_attributes in [true, false]

P2 = projective_space(NormalToricVariety, 2; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/line_bundles.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Line bundles (set_attributes = $set_attributes)" for set_attributes in [true, false]

dP1 = del_pezzo_surface(NormalToricVariety, 1; set_attributes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Normal toric varieties (set_attributes = $set_attributes)" for set_attributes in [true, false]

ntv = normal_toric_variety(Oscar.normal_fan(Oscar.cube(2)))
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/projective_spaces.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "(Weighted) projective spaces (set_attributes = $set_attributes)" for set_attributes in [true, false]

P2 = projective_space(NormalToricVariety, 2; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/subvarieties.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Closed subvarieties (set_attributes = $set_attributes)" for set_attributes in [true, false]

antv = normal_toric_variety([[1, 0, 0], [1, 0, 1], [1, 1, 1], [1, 1, 0]], [[1, 2, 3, 4]])
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/toric_blowups.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Blowup of toric varieties (set_attributes = $set_attributes)" for set_attributes in [true, false]

P2 = projective_space(NormalToricVariety, 2; set_attributes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Torus-invariant divisor classes (set_attributes = $set_attributes)" for set_attributes in [true, false]

F5 = hirzebruch_surface(NormalToricVariety, 5; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/toric_divisors.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Torus-invariant divisors (set_attributes = $set_attributes)" for set_attributes in [true, false]

F5 = hirzebruch_surface(NormalToricVariety, 5; set_attributes)
Expand Down
3 changes: 0 additions & 3 deletions test/AlgebraicGeometry/ToricVarieties/toric_morphisms.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oscar
using Test

@testset "Toric morphisms (set_attributes = $set_attributes)" for set_attributes in [true, false]

source = projective_space(NormalToricVariety, 1; set_attributes)
Expand Down

0 comments on commit 3b64d46

Please sign in to comment.