Skip to content

Commit

Permalink
Polytopes: intersect, dual_cone, polarize
Browse files Browse the repository at this point in the history
  • Loading branch information
lkastner committed Sep 29, 2021
1 parent 8f052e6 commit bf5ed46
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/PolyhedralGeometry/Polyhedra/auxiliary.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ lineality_space(P::Polyhedron)
nfacets(P::Polyhedron)
normalized_volume(P::Polyhedron)
nvertices(P::Polyhedron)
polarize(P::Polyhedron)
print_constraints(A::AnyVecOrMat, b::AbstractVector; trivial::Bool = false)
print_constraints(P::Polyhedron; trivial::Bool = false)
rays(P::Polyhedron)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/PolyhedralGeometry/cones.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ f_vector(C::Cone)
hilbert_basis(C::Cone)
codim(C::Cone)
dim(C::Cone)
dual_cone(C::Cone)
intersect(C0::Cone, C1::Cone)
ispointed(C::Cone)
isfulldimensional(C::Cone)
lineality_dim(C::Cone)
Expand Down
56 changes: 56 additions & 0 deletions src/Polytopes/Cone/standard_constructions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
###############################################################################
###############################################################################
### Standard constructions
###############################################################################
###############################################################################
@doc Markdown.doc"""
intersect(C0::Cone, C1::Cone)
Return the intersection $C0 \cap C1$ of `C0` and `C1`.
# Examples
```jldoctest
julia> C0 = positive_hull([1 0])
A polyhedral cone in ambient dimension 2
julia> C1 = positive_hull([0 1])
A polyhedral cone in ambient dimension 2
julia> C01 = intersect(C0, C1)
A polyhedral cone in ambient dimension 2
julia> rays(C01)
0-element VectorIterator{RayVector{Polymake.Rational}}
julia> dim(C01)
0
```
"""
function intersect(C0::Cone, C1::Cone)
return Cone(Polymake.polytope.intersection(pm_cone(C0), pm_cone(C1)))
end


@doc Markdown.doc"""
dual_cone(C::Cone)
Return the dual cone of `C` consisting of all those linear functions that
evaluate positively on all o `C`.
# Examples
```jldoctest
julia> C = positive_hull([1 0; -1 2])
A polyhedral cone in ambient dimension 2
julia> Cv = dual_cone(C)
A polyhedral cone in ambient dimension 2
julia> rays(Cv)
2-element VectorIterator{RayVector{Polymake.Rational}}:
[1, 1/2]
[0, 1]
```
"""
function dual_cone(C::Cone)
return Cone(Polymake.polytope.polarize(pm_cone(C)))
end
27 changes: 27 additions & 0 deletions src/Polytopes/Polyhedron/standard_constructions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -681,3 +681,30 @@ Essentially, one can read the
upperbounds.
"""
upper_bound_theorem(d::Int,n::Int) = Polyhedron(Polymake.polytope.upper_bound_theorem(d,n))


@doc Markdown.doc"""
polarize(P::Polyhedron)
Return the polar dual of the polyhedron `P`, consisting of all linear functions
whose absolute value on `P` does not exceed 1.
# Examples
```jldoctest
julia> square = cube(2)
A polyhedron in ambient dimension 2
julia> P = polarize(square)
A polyhedron in ambient dimension 2
julia> vertices(P)
4-element VectorIterator{PointVector{Polymake.Rational}}:
[1, 0]
[-1, 0]
[0, 1]
[0, -1]
```
"""
function polarize(P::Polyhedron)
return Polyhedron(Polymake.polytope.polarize(pm_polytope(P)))
end
3 changes: 3 additions & 0 deletions src/Polytopes/Polytopes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export Cone,
cross,
cube,
dim,
dual_cone,
faces,
facets,
facets_as_halfspace_matrix_pair,
Expand Down Expand Up @@ -82,6 +83,7 @@ export Cone,
objective_function,
orbit_polytope,
point_matrix,
polarize,
print_constraints,
product,
recession_cone,
Expand Down Expand Up @@ -109,6 +111,7 @@ include("iterators.jl")
include("Polyhedron/constructors.jl")
include("Cone/constructors.jl")
include("Cone/properties.jl")
include("Cone/standard_constructions.jl")
include("Polyhedron/properties.jl")
include("Polyhedron/standard_constructions.jl")
include("PolyhedralFan/constructors.jl")
Expand Down

0 comments on commit bf5ed46

Please sign in to comment.