Parents for Polyhedra#
- sage.geometry.polyhedron.parent.Polyhedra(ambient_space_or_base_ring, ambient_dim, backend=None, ambient_space=None, base_ring=None)[source]#
Construct a suitable parent class for polyhedra
INPUT:
base_ring
– A ring. Currently there are backends for \(\ZZ\), \(\QQ\), and \(\RDF\).ambient_dim
– integer. The ambient space dimension.ambient_space
– A free module.backend
– string. The name of the backend for computations. There areseveral backends implemented:
backend="ppl"
uses the Parma Polyhedra Librarybackend="cdd"
uses CDDbackend="normaliz"
uses normalizbackend="polymake"
uses polymakebackend="field"
a generic Sage implementation
OUTPUT:
A parent class for polyhedra over the given base ring if the backend supports it. If not, the parent base ring can be larger (for example, \(\QQ\) instead of \(\ZZ\)). If there is no implementation at all, a
ValueError
is raised.EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(AA, 3) # needs sage.rings.number_field Polyhedra in AA^3 sage: Polyhedra(ZZ, 3) Polyhedra in ZZ^3 sage: type(_) <class 'sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl_with_category'> sage: Polyhedra(QQ, 3, backend='cdd') Polyhedra in QQ^3 sage: type(_) <class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_cdd_with_category'>
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(AA, Integer(3)) # needs sage.rings.number_field Polyhedra in AA^3 >>> Polyhedra(ZZ, Integer(3)) Polyhedra in ZZ^3 >>> type(_) <class 'sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl_with_category'> >>> Polyhedra(QQ, Integer(3), backend='cdd') Polyhedra in QQ^3 >>> type(_) <class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_cdd_with_category'>
CDD does not support integer polytopes directly:
sage: Polyhedra(ZZ, 3, backend='cdd') Polyhedra in QQ^3
>>> from sage.all import * >>> Polyhedra(ZZ, Integer(3), backend='cdd') Polyhedra in QQ^3
Using a more general form of the constructor:
sage: V = VectorSpace(QQ, 3) sage: Polyhedra(V) is Polyhedra(QQ, 3) True sage: Polyhedra(V, backend='field') is Polyhedra(QQ, 3, 'field') True sage: Polyhedra(backend='field', ambient_space=V) is Polyhedra(QQ, 3, 'field') True sage: M = FreeModule(ZZ, 2) sage: Polyhedra(M, backend='ppl') is Polyhedra(ZZ, 2, 'ppl') True
>>> from sage.all import * >>> V = VectorSpace(QQ, Integer(3)) >>> Polyhedra(V) is Polyhedra(QQ, Integer(3)) True >>> Polyhedra(V, backend='field') is Polyhedra(QQ, Integer(3), 'field') True >>> Polyhedra(backend='field', ambient_space=V) is Polyhedra(QQ, Integer(3), 'field') True >>> M = FreeModule(ZZ, Integer(2)) >>> Polyhedra(M, backend='ppl') is Polyhedra(ZZ, Integer(2), 'ppl') True
- class sage.geometry.polyhedron.parent.Polyhedra_QQ_cdd(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_QQ_cdd
- class sage.geometry.polyhedron.parent.Polyhedra_QQ_normaliz(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_QQ_normaliz
- class sage.geometry.polyhedron.parent.Polyhedra_QQ_ppl(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_QQ_ppl
- class sage.geometry.polyhedron.parent.Polyhedra_RDF_cdd(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_RDF_cdd
- class sage.geometry.polyhedron.parent.Polyhedra_ZZ_normaliz(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_ZZ_normaliz
- class sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_ZZ_ppl
- class sage.geometry.polyhedron.parent.Polyhedra_base(base_ring, ambient_dim, backend)[source]#
Bases:
UniqueRepresentation
,Parent
Polyhedra in a fixed ambient space.
INPUT:
base_ring
– eitherZZ
,QQ
, orRDF
. The base ring of the ambient module/vector space.ambient_dim
– integer. The ambient space dimension.backend
– string. The name of the backend for computations. There areseveral backends implemented:
backend="ppl"
uses the Parma Polyhedra Librarybackend="cdd"
uses CDDbackend="normaliz"
uses normalizbackend="polymake"
uses polymakebackend="field"
a generic Sage implementation
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(ZZ, 3) Polyhedra in ZZ^3
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(ZZ, Integer(3)) Polyhedra in ZZ^3
- Hrepresentation_space()[source]#
Return the linear space containing the H-representation vectors.
OUTPUT:
A free module over the base ring of dimension
ambient_dim()
+ 1.EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(ZZ, 2).Hrepresentation_space() Ambient free module of rank 3 over the principal ideal domain Integer Ring
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(ZZ, Integer(2)).Hrepresentation_space() Ambient free module of rank 3 over the principal ideal domain Integer Ring
- Vrepresentation_space()[source]#
Return the ambient vector space.
This is the vector space or module containing the Vrepresentation vectors.
OUTPUT:
A free module over the base ring of dimension
ambient_dim()
.EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 4).Vrepresentation_space() Vector space of dimension 4 over Rational Field sage: Polyhedra(QQ, 4).ambient_space() Vector space of dimension 4 over Rational Field
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(4)).Vrepresentation_space() Vector space of dimension 4 over Rational Field >>> Polyhedra(QQ, Integer(4)).ambient_space() Vector space of dimension 4 over Rational Field
- ambient_dim()[source]#
Return the dimension of the ambient space.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 3).ambient_dim() 3
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(3)).ambient_dim() 3
- ambient_space()[source]#
Return the ambient vector space.
This is the vector space or module containing the Vrepresentation vectors.
OUTPUT:
A free module over the base ring of dimension
ambient_dim()
.EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 4).Vrepresentation_space() Vector space of dimension 4 over Rational Field sage: Polyhedra(QQ, 4).ambient_space() Vector space of dimension 4 over Rational Field
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(4)).Vrepresentation_space() Vector space of dimension 4 over Rational Field >>> Polyhedra(QQ, Integer(4)).ambient_space() Vector space of dimension 4 over Rational Field
- an_element()[source]#
Return a Polyhedron.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 4).an_element() A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 5 vertices
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(4)).an_element() A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 5 vertices
- backend()[source]#
Return the backend.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 3).backend() 'ppl'
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(3)).backend() 'ppl'
- base_extend(base_ring, backend=None, ambient_dim=None)[source]#
Return the base extended parent.
INPUT:
base_ring
,backend
– seePolyhedron()
.ambient_dim
– if notNone
change ambient dimension accordingly.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(ZZ, 3).base_extend(QQ) Polyhedra in QQ^3 sage: Polyhedra(ZZ, 3).an_element().base_extend(QQ) A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices sage: Polyhedra(QQ, 2).base_extend(ZZ) Polyhedra in QQ^2
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(ZZ, Integer(3)).base_extend(QQ) Polyhedra in QQ^3 >>> Polyhedra(ZZ, Integer(3)).an_element().base_extend(QQ) A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices >>> Polyhedra(QQ, Integer(2)).base_extend(ZZ) Polyhedra in QQ^2
- change_ring(base_ring, backend=None, ambient_dim=None)[source]#
Return the parent with the new base ring.
INPUT:
base_ring
,backend
– seePolyhedron()
.ambient_dim
– if notNone
change ambient dimension accordingly.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(ZZ, 3).change_ring(QQ) Polyhedra in QQ^3 sage: Polyhedra(ZZ, 3).an_element().change_ring(QQ) A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices sage: Polyhedra(RDF, 3).change_ring(QQ).backend() 'cdd' sage: Polyhedra(QQ, 3).change_ring(ZZ, ambient_dim=4) Polyhedra in ZZ^4 sage: Polyhedra(QQ, 3, backend='cdd').change_ring(QQ, ambient_dim=4).backend() 'cdd'
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(ZZ, Integer(3)).change_ring(QQ) Polyhedra in QQ^3 >>> Polyhedra(ZZ, Integer(3)).an_element().change_ring(QQ) A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices >>> Polyhedra(RDF, Integer(3)).change_ring(QQ).backend() 'cdd' >>> Polyhedra(QQ, Integer(3)).change_ring(ZZ, ambient_dim=Integer(4)) Polyhedra in ZZ^4 >>> Polyhedra(QQ, Integer(3), backend='cdd').change_ring(QQ, ambient_dim=Integer(4)).backend() 'cdd'
- empty()[source]#
Return the empty polyhedron.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: P = Polyhedra(QQ, 4) sage: P.empty() The empty polyhedron in QQ^4 sage: P.empty().is_empty() True
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> P = Polyhedra(QQ, Integer(4)) >>> P.empty() The empty polyhedron in QQ^4 >>> P.empty().is_empty() True
- list()[source]#
Return the two polyhedra in ambient dimension 0, raise an error otherwise
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: P = Polyhedra(QQ, 3) sage: P.cardinality() +Infinity sage: # needs sage.rings.number_field sage: P = Polyhedra(AA, 0) sage: P.category() Category of finite enumerated polyhedral sets over Algebraic Real Field sage: P.list() [The empty polyhedron in AA^0, A 0-dimensional polyhedron in AA^0 defined as the convex hull of 1 vertex] sage: P.cardinality() 2
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> P = Polyhedra(QQ, Integer(3)) >>> P.cardinality() +Infinity >>> # needs sage.rings.number_field >>> P = Polyhedra(AA, Integer(0)) >>> P.category() Category of finite enumerated polyhedral sets over Algebraic Real Field >>> P.list() [The empty polyhedron in AA^0, A 0-dimensional polyhedron in AA^0 defined as the convex hull of 1 vertex] >>> P.cardinality() 2
- recycle(polyhedron)[source]#
Recycle the H/V-representation objects of a polyhedron.
This speeds up creation of new polyhedra by reusing objects. After recycling a polyhedron object, it is not in a consistent state any more and neither the polyhedron nor its H/V-representation objects may be used any more.
INPUT:
polyhedron
– a polyhedron whose parent isself
.
EXAMPLES:
sage: p = Polyhedron([(0,0),(1,0),(0,1)]) sage: p.parent().recycle(p)
>>> from sage.all import * >>> p = Polyhedron([(Integer(0),Integer(0)),(Integer(1),Integer(0)),(Integer(0),Integer(1))]) >>> p.parent().recycle(p)
- some_elements()[source]#
Return a list of some elements of the semigroup.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: Polyhedra(QQ, 4).some_elements() [A 3-dimensional polyhedron in QQ^4 defined as the convex hull of 4 vertices, A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 4 rays, A 2-dimensional polyhedron in QQ^4 defined as the convex hull of 2 vertices and 1 ray, The empty polyhedron in QQ^4] sage: Polyhedra(ZZ, 0).some_elements() [The empty polyhedron in ZZ^0, A 0-dimensional polyhedron in ZZ^0 defined as the convex hull of 1 vertex]
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> Polyhedra(QQ, Integer(4)).some_elements() [A 3-dimensional polyhedron in QQ^4 defined as the convex hull of 4 vertices, A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 4 rays, A 2-dimensional polyhedron in QQ^4 defined as the convex hull of 2 vertices and 1 ray, The empty polyhedron in QQ^4] >>> Polyhedra(ZZ, Integer(0)).some_elements() [The empty polyhedron in ZZ^0, A 0-dimensional polyhedron in ZZ^0 defined as the convex hull of 1 vertex]
- universe()[source]#
Return the entire ambient space as polyhedron.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: P = Polyhedra(QQ, 4) sage: P.universe() A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 4 lines sage: P.universe().is_universe() True
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> P = Polyhedra(QQ, Integer(4)) >>> P.universe() A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex and 4 lines >>> P.universe().is_universe() True
- zero()[source]#
Return the polyhedron consisting of the origin, which is the neutral element for Minkowski addition.
EXAMPLES:
sage: from sage.geometry.polyhedron.parent import Polyhedra sage: p = Polyhedra(QQ, 4).zero(); p A 0-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex sage: p + p == p True
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import Polyhedra >>> p = Polyhedra(QQ, Integer(4)).zero(); p A 0-dimensional polyhedron in QQ^4 defined as the convex hull of 1 vertex >>> p + p == p True
- class sage.geometry.polyhedron.parent.Polyhedra_field(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_field
- class sage.geometry.polyhedron.parent.Polyhedra_normaliz(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_normaliz
- class sage.geometry.polyhedron.parent.Polyhedra_number_field(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_number_field
- class sage.geometry.polyhedron.parent.Polyhedra_polymake(base_ring, ambient_dim, backend)[source]#
Bases:
Polyhedra_base
- Element[source]#
alias of
Polyhedron_polymake
- sage.geometry.polyhedron.parent.does_backend_handle_base_ring(backend)[source]#
Return true, if
backend
can handlebase_ring
.EXAMPLES:
sage: from sage.geometry.polyhedron.parent import does_backend_handle_base_ring sage: does_backend_handle_base_ring(QQ, 'ppl') True sage: does_backend_handle_base_ring(QQ[sqrt(5)], 'ppl') # needs sage.rings.number_field sage.symbolic False sage: does_backend_handle_base_ring(QQ[sqrt(5)], 'field') # needs sage.rings.number_field sage.symbolic True
>>> from sage.all import * >>> from sage.geometry.polyhedron.parent import does_backend_handle_base_ring >>> does_backend_handle_base_ring(QQ, 'ppl') True >>> does_backend_handle_base_ring(QQ[sqrt(Integer(5))], 'ppl') # needs sage.rings.number_field sage.symbolic False >>> does_backend_handle_base_ring(QQ[sqrt(Integer(5))], 'field') # needs sage.rings.number_field sage.symbolic True