Convex Sets#
- class sage.geometry.convex_set.AffineHullProjectionData(image=None, projection_linear_map=None, projection_translation=None, section_linear_map=None, section_translation=None)#
Bases:
object
- class sage.geometry.convex_set.ConvexSet_base#
Bases:
sage.structure.sage_object.SageObject
,sage.sets.set.Set_base
Abstract base class for convex sets.
- affine_hull(*args, **kwds)#
Return the affine hull of
self
as a polyhedron.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_compact sage: class EmbeddedDisk(ConvexSet_compact): ....: def an_affine_basis(self): ....: return [vector([1, 0, 0]), vector([1, 1, 0]), vector([1, 0, 1])] sage: O = EmbeddedDisk() sage: O.dim() 2 sage: O.affine_hull() A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 1 vertex and 2 lines
- affine_hull_projection(as_convex_set=None, as_affine_map=False, orthogonal=False, orthonormal=False, extend=False, minimal=False, return_all_data=False, **kwds)#
Return
self
projected into its affine hull.Each convex set is contained in some smallest affine subspace (possibly the entire ambient space) – its affine hull. We provide an affine linear map that projects the ambient space of the convex set to the standard Euclidean space of dimension of the convex set, which restricts to a bijection from the affine hull.
The projection map is not unique; some parameters control the choice of the map. Other parameters control the output of the function.
EXAMPLES:
sage: P = Polyhedron(vertices=[[1, 0], [0, 1]]) sage: ri_P = P.relative_interior(); ri_P Relative interior of a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices sage: ri_P.affine_hull_projection(as_affine_map=True) (Vector space morphism represented by the matrix: [1] [0] Domain: Vector space of dimension 2 over Rational Field Codomain: Vector space of dimension 1 over Rational Field, (0)) sage: P_aff = P.affine_hull_projection(); P_aff A 1-dimensional polyhedron in ZZ^1 defined as the convex hull of 2 vertices sage: ri_P_aff = ri_P.affine_hull_projection(); ri_P_aff Relative interior of a 1-dimensional polyhedron in QQ^1 defined as the convex hull of 2 vertices sage: ri_P_aff.closure() == P_aff True
- ambient()#
Return the ambient convex set or space.
The default implementation delegates to
ambient_vector_space()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def ambient_vector_space(self, base_field=None): ....: return (base_field or QQ)^2001 sage: ExampleSet().ambient() Vector space of dimension 2001 over Rational Field
- ambient_dim()#
Return the dimension of the ambient convex set or space.
The default implementation obtains it from
ambient()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def ambient(self): ....: return QQ^7 sage: ExampleSet().ambient_dim() 7
- ambient_dimension()#
Return the dimension of the ambient convex set or space.
This is the same as
ambient_dim()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def ambient_dim(self): ....: return 91 sage: ExampleSet().ambient_dimension() 91
- ambient_vector_space(base_field=None)#
Return the ambient vector space.
Subclasses must provide an implementation of this method.
The default implementations of
ambient()
,ambient_dim()
,ambient_dimension()
use this method.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: C = ConvexSet_base() sage: C.ambient_vector_space() Traceback (most recent call last): ... NotImplementedError: <abstract method ambient_vector_space at ...>
- an_affine_basis()#
Return points that form an affine basis for the affine hull.
The points are guaranteed to lie in the topological closure of
self
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: C = ConvexSet_base() sage: C.an_affine_basis() Traceback (most recent call last): ... TypeError: 'NotImplementedType' object is not callable
- an_element()#
Return a point of
self
.If
self
is empty, anEmptySetError
will be raised.The default implementation delegates to
_some_elements_()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_compact sage: class BlueBox(ConvexSet_compact): ....: def _some_elements_(self): ....: yield 'blue' ....: yield 'cyan' sage: BlueBox().an_element() 'blue'
- cardinality()#
Return the cardinality of this set.
OUTPUT:
Either an integer or
Infinity
.EXAMPLES:
sage: p = LatticePolytope([], lattice=ToricLattice(3).dual()); p -1-d lattice polytope in 3-d lattice M sage: p.cardinality() 0 sage: q = Polyhedron(ambient_dim=2); q The empty polyhedron in ZZ^2 sage: q.cardinality() 0 sage: r = Polyhedron(rays=[(1, 0)]); r A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 ray sage: r.cardinality() +Infinity
- cartesian_product(other)#
Return the Cartesian product.
INPUT:
other
– another convex set
OUTPUT:
The Cartesian product of
self
andother
.
- closure()#
Return the topological closure of
self
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_closed sage: C = ConvexSet_closed() sage: C.closure() is C True
- codim()#
Return the codimension of
self
inself.ambient()
.EXAMPLES:
sage: P = Polyhedron(vertices=[(1,2,3)], rays=[(1,0,0)]) sage: P.codimension() 2
An alias is
codim()
:sage: P.codim() 2
- codimension()#
Return the codimension of
self
inself.ambient()
.EXAMPLES:
sage: P = Polyhedron(vertices=[(1,2,3)], rays=[(1,0,0)]) sage: P.codimension() 2
An alias is
codim()
:sage: P.codim() 2
- contains(point)#
Test whether
self
contains the givenpoint
.INPUT:
point
– a point or its coordinates
- dilation(scalar)#
Return the dilated (uniformly stretched) set.
INPUT:
scalar
– A scalar, not necessarily inbase_ring()
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_compact sage: class GlorifiedPoint(ConvexSet_compact): ....: def __init__(self, p): ....: self._p = p ....: def ambient_vector_space(self): ....: return self._p.parent().vector_space() ....: def linear_transformation(self, linear_transf): ....: return GlorifiedPoint(linear_transf * self._p) sage: P = GlorifiedPoint(vector([2, 3])) sage: P.dilation(10)._p (20, 30)
- dim()#
Return the dimension of
self
.Subclasses must provide an implementation of this method or of the method
an_affine_basis()
.
- dimension()#
Return the dimension of
self
.This is the same as
dim()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def dim(self): ....: return 42 sage: ExampleSet().dimension() 42
- interior()#
Return the topological interior of
self
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_open sage: C = ConvexSet_open() sage: C.interior() is C True
- intersection(other)#
Return the intersection of
self
andother
.INPUT:
other
– another convex set
OUTPUT:
The intersection.
- is_closed()#
Return whether
self
is closed.The default implementation of this method only knows that the empty set, a singleton set, and the ambient space are closed.
OUTPUT:
Boolean.
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def dim(self): ....: return 0 sage: ExampleSet().is_closed() True
- is_compact()#
Return whether
self
is compact.The default implementation of this method only knows that a non-closed set cannot be compact, and that the empty set and a singleton set are compact.
OUTPUT:
Boolean.
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ….: def dim(self): ….: return 0 sage: ExampleSet().is_compact() True
- is_empty()#
Test whether
self
is the empty set.OUTPUT:
Boolean.
EXAMPLES:
sage: p = LatticePolytope([], lattice=ToricLattice(3).dual()); p -1-d lattice polytope in 3-d lattice M sage: p.is_empty() True
- is_finite()#
Test whether
self
is a finite set.OUTPUT:
Boolean.
EXAMPLES:
sage: p = LatticePolytope([], lattice=ToricLattice(3).dual()); p -1-d lattice polytope in 3-d lattice M sage: p.is_finite() True sage: q = Polyhedron(ambient_dim=2); q The empty polyhedron in ZZ^2 sage: q.is_finite() True sage: r = Polyhedron(rays=[(1, 0)]); r A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 ray sage: r.is_finite() False
- is_full_dimensional()#
Return whether
self
is full dimensional.OUTPUT:
Boolean. Whether the polyhedron is not contained in any strict affine subspace.
EXAMPLES:
sage: c = Cone([(1,0)]) sage: c.is_full_dimensional() False sage: polytopes.hypercube(3).is_full_dimensional() True sage: Polyhedron(vertices=[(1,2,3)], rays=[(1,0,0)]).is_full_dimensional() False
- is_open()#
Return whether
self
is open.The default implementation of this method only knows that the empty set and the ambient space are open.
OUTPUT:
Boolean.
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def is_empty(self): ....: return False ....: def is_universe(self): ....: return True sage: ExampleSet().is_open() True
- is_relatively_open()#
Return whether
self
is relatively open.The default implementation of this method only knows that open sets are also relatively open, and in addition singletons are relatively open.
OUTPUT:
Boolean.
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_base sage: class ExampleSet(ConvexSet_base): ....: def is_open(self): ....: return True sage: ExampleSet().is_relatively_open() True
- is_universe()#
Test whether
self
is the whole ambient space.OUTPUT:
Boolean.
- linear_transformation(linear_transf)#
Return the linear transformation of
self
.INPUT:
linear_transf
– a matrix
- relative_interior()#
Return the relative interior of
self
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_relatively_open sage: C = ConvexSet_relatively_open() sage: C.relative_interior() is C True
- representative_point()#
Return a “generic” point of
self
.OUTPUT:
A point in the relative interior of
self
as a coordinate vector.EXAMPLES:
sage: C = Cone([[1, 2, 0], [2, 1, 0]]) sage: C.representative_point() (1, 1, 0)
- some_elements()#
Return a list of some points of
self
.If
self
is empty, an empty list is returned; no exception will be raised.The default implementation delegates to
_some_elements_()
.EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_compact sage: class BlueBox(ConvexSet_compact): ....: def _some_elements_(self): ....: yield 'blue' ....: yield 'cyan' sage: BlueBox().some_elements() ['blue', 'cyan']
- translation(displacement)#
Return the translation of
self
by adisplacement
vector.INPUT:
displacement
– a displacement vector or a list/tuple of coordinates that determines a displacement vector
- class sage.geometry.convex_set.ConvexSet_closed#
Bases:
sage.geometry.convex_set.ConvexSet_base
Abstract base class for closed convex sets.
- is_closed()#
Return whether
self
is closed.OUTPUT:
Boolean.
EXAMPLES:
sage: hcube = polytopes.hypercube(5) sage: hcube.is_closed() True
- is_open()#
Return whether
self
is open.OUTPUT:
Boolean.
EXAMPLES:
sage: hcube = polytopes.hypercube(5) sage: hcube.is_open() False sage: zerocube = polytopes.hypercube(0) sage: zerocube.is_open() True
- class sage.geometry.convex_set.ConvexSet_compact#
Bases:
sage.geometry.convex_set.ConvexSet_closed
Abstract base class for compact convex sets.
- is_compact()#
Return whether
self
is compact.OUTPUT:
Boolean.
EXAMPLES:
sage: cross3 = lattice_polytope.cross_polytope(3) sage: cross3.is_compact() True
- is_relatively_open()#
Return whether
self
is open.OUTPUT:
Boolean.
EXAMPLES:
sage: hcube = polytopes.hypercube(5) sage: hcube.is_open() False sage: zerocube = polytopes.hypercube(0) sage: zerocube.is_open() True
- is_universe()#
Return whether
self
is the whole ambient spaceOUTPUT:
Boolean.
EXAMPLES:
sage: cross3 = lattice_polytope.cross_polytope(3) sage: cross3.is_universe() False sage: point0 = LatticePolytope([[]]); point0 0-d reflexive polytope in 0-d lattice M sage: point0.is_universe() True
- class sage.geometry.convex_set.ConvexSet_open#
Bases:
sage.geometry.convex_set.ConvexSet_relatively_open
Abstract base class for open convex sets.
- is_closed()#
Return whether
self
is closed.OUTPUT:
Boolean.
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_open sage: class OpenBall(ConvexSet_open): ....: def dim(self): ....: return 3 ....: def is_universe(self): ....: return False sage: OpenBall().is_closed() False
- is_open()#
Return whether
self
is open.OUTPUT:
Boolean.
EXAMPLES:
sage: from sage.geometry.convex_set import ConvexSet_open sage: b = ConvexSet_open() sage: b.is_open() True
- class sage.geometry.convex_set.ConvexSet_relatively_open#
Bases:
sage.geometry.convex_set.ConvexSet_base
Abstract base class for relatively open convex sets.
- is_open()#
Return whether
self
is open.OUTPUT:
Boolean.
EXAMPLES:
sage: segment = Polyhedron([[1, 2], [3, 4]]) sage: ri_segment = segment.relative_interior() sage: ri_segment.is_open() False
- is_relatively_open()#
Return whether
self
is relatively open.OUTPUT:
Boolean.
EXAMPLES:
sage: segment = Polyhedron([[1, 2], [3, 4]]) sage: ri_segment = segment.relative_interior() sage: ri_segment.is_relatively_open() True