Skip to content

Commit

Permalink
Fix zero-dimensional cone in cones
Browse files Browse the repository at this point in the history
  • Loading branch information
paemurru committed Nov 20, 2024
1 parent aa41156 commit 23716cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/PolyhedralGeometry/PolyhedralFan/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,17 @@ julia> cones(PF, 2)
"""
function cones(PF::_FanLikeType, cone_dim::Int)
l = cone_dim - length(lineality_space(PF))
l < 1 && return nothing
return SubObjectIterator{Cone{_get_scalar_type(PF)}}(
t = Cone{_get_scalar_type(PF)}
l < 0 && return _empty_subobjectiterator(t, PF)
l == 0 && length(lineality_space(PF)) == 0 && return SubObjectIterator{t}(
PF, (_, _, _) -> cone(zeros(Int, ambient_dim(PF))), 1, NamedTuple()
)

# The function `lineality_space` returns a ray even in the case where
# the lineality space is actually a line.
l == 0 && length(lineality_space(PF)) > 0 && return error("Not implemented.")

return SubObjectIterator{t}(
PF, _cone_of_dim, size(Polymake.fan.cones_of_dim(pm_object(PF), l), 1), (c_dim=l,)
)
end
Expand Down
9 changes: 8 additions & 1 deletion test/PolyhedralGeometry/polyhedral_fan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,18 @@
@test size(cones(F2, 2)) == (2,)
@test lineality_space(cones(F2, 2)[1]) == [[0, 1, 0]]
@test rays.(cones(F2, 2)) == [[], []]
@test isnothing(cones(F2, 1))
@test _check_im_perm_rows(ray_indices(cones(F1, 2)), incidence1)
@test _check_im_perm_rows(incidence_matrix(cones(F1, 2)), incidence1)
@test _check_im_perm_rows(cones(IncidenceMatrix, F1, 2), incidence1)

A3 = affine_space(NormalToricVariety, 3)
@test length(cones(A3, 1)) == 3
@test length(cones(A3, 0)) == 1
@test length(cones(A3, -1)) == 0
@test cones(A3, 1) isa SubObjectIterator{Cone{QQFieldElem}}
@test cones(A3, 0) isa SubObjectIterator{Cone{QQFieldElem}}
@test cones(A3, -1) isa SubObjectIterator{Cone{QQFieldElem}}

II = ray_indices(maximal_cones(NFsquare))
NF0 = polyhedral_fan(II, rays(NFsquare))
@test n_rays(NF0) == 4
Expand Down

0 comments on commit 23716cc

Please sign in to comment.