Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
RelativeInterior: Add documentation, tests, comparison methods, metho…
Browse files Browse the repository at this point in the history
…d relative_interior
  • Loading branch information
Matthias Koeppe committed Jun 6, 2021
1 parent 6869673 commit 021d073
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,18 @@
"""

# ****************************************************************************
# Copyright (C) 2010 Volker Braun <vbraun.name@gmail.com>
# Copyright (C) 2012 Andrey Novoseltsev <novoselt@gmail.com>
# Copyright (C) 2010 William Stein <wstein@gmail.com>
# Copyright (C) 2010-2014 Volker Braun <vbraun.name@gmail.com>
# Copyright (C) 2010-2018 Andrey Novoseltsev <novoselt@gmail.com>
# Copyright (C) 2010 William Stein <wstein@gmail.com>
# Copyright (C) 2012 Christian Stump
# Copyright (C) 2014-2018 Frédéric Chapoton
# Copyright (C) 2014 Peter Bruin
# Copyright (C) 2015-2017 Jori Mäntysalo
# Copyright (C) 2015-2020 Michael Orlitzky
# Copyright (C) 2016-2020 John H. Palmieri
# Copyright (C) 2018 David Coudert
# Copyright (C) 2019-2020 Jonathan Kliem
# Copyright (C) 2020-2021 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
127 changes: 125 additions & 2 deletions src/sage/geometry/relative_interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,96 @@

class RelativeInterior(SageObject):

"""
r"""
The relative interior of a polyhedron or cone
This class should not be used directly. Use methods
:meth:`~sage.geometry.polyhedron.Polyhedron_base.relative_interior`,
:meth:`~sage.geometry.polyhedron.Polyhedron_base.interior`,
:meth:`~sage.geometry.cone.ConvexRationalPolyhedralCone.relative_interior`,
:meth:`~sage.geometry.cone.ConvexRationalPolyhedralCone.interior` instead.
EXAMPLES::
sage: segment = Polyhedron([[1, 2], [3, 4]])
sage: segment.relative_interior()
Relative interior of
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: octant = Cone([(1,0,0), (0,1,0), (0,0,1)])
sage: octant.relative_interior()
Relative interior of 3-d cone in 3-d lattice N
"""

def __init__(self, polyhedron):
r"""
Initialize ``self``.
INPUT:
- ``polyhedron`` - an instance of :class:`Polyhedron_base` or
:class:`ConvexRationalPolyhedralCone`.
TESTS::
sage: P = Polyhedron()
sage: from sage.geometry.relative_interior import RelativeInterior
sage: TestSuite(RelativeInterior(P)).run()
"""
self._polyhedron = polyhedron

def __contains__(self, point):
r"""
Return whether ``self`` contains ``point``.
EXAMPLES::
sage: octant = Cone([(1,0,0), (0,1,0), (0,0,1)])
sage: ri_octant = octant.relative_interior(); ri_octant
Relative interior of 3-d cone in 3-d lattice N
sage: (1, 1, 1) in ri_octant
True
sage: (1, 0, 0) in ri_octant
False
"""
return self._polyhedron.relative_interior_contains(point)

def relative_interior(self):
r"""
Return the relative interior of ``self``.
As ``self`` is already relatively open, this method just returns ``self``.
EXAMPLES::
sage: segment = Polyhedron([[1, 2], [3, 4]])
sage: ri_segment = segment.relative_interior(); ri_segment
Relative interior of
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: ri_segment.relative_interior() is ri_segment
True
"""
return self

def closure(self):
r"""
Return the topological closure of ``self``.
EXAMPLES::
sage: segment = Polyhedron([[1, 2], [3, 4]])
sage: ri_segment = segment.relative_interior(); ri_segment
Relative interior of
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: ri_segment.closure() is segment
True
"""
return self._polyhedron

def _repr_(self):
"""
r"""
Return a description of ``self``.
EXAMPLES::
Expand All @@ -46,3 +121,51 @@ def _repr_(self):
if repr_P.startswith('A '):
repr_P = 'a ' + repr_P[2:]
return 'Relative interior of ' + repr_P

def __eq__(self, other):
r"""
Compare ``self`` and ``other``.
INPUT:
- ``other`` -- a polyhedron
EXAMPLES::
sage: segment = Polyhedron([[1, 2], [3, 4]])
sage: ri_segment = segment.relative_interior(); ri_segment
Relative interior of
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: segment2 = Polyhedron([[1, 2], [3, 4]], base_ring=AA)
sage: ri_segment2 = segment2.relative_interior(); ri_segment2
Relative interior of
a 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
sage: ri_segment == ri_segment2
True
"""
return self._polyhedron == other._polyhedron

def __ne__(self, other):
r"""
Compare ``self`` and ``other``.
INPUT:
- ``other`` -- a polyhedron
TESTS::
sage: segment = Polyhedron([[1, 2], [3, 4]])
sage: ri_segment = segment.relative_interior(); ri_segment
Relative interior of
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: segment2 = Polyhedron([[1, 2], [3, 4]], base_ring=AA)
sage: ri_segment2 = segment2.relative_interior(); ri_segment2
Relative interior of
a 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
sage: ri_segment != ri_segment2
False
"""
return self._polyhedron != other._polyhedron

0 comments on commit 021d073

Please sign in to comment.