Skip to content
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
17 changes: 15 additions & 2 deletions src/PolyhedralGeometry/PolyhedralFan/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,21 @@ 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 || dim(PF) == -1) && return _empty_subobjectiterator(t, PF)

if l == 0
return SubObjectIterator{t}(
PF,
(_, _, _) -> positive_hull(
coefficient_field(PF), zeros(Int, ambient_dim(PF)), lineality_space(PF)
),
1,
NamedTuple(),
)
end

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