The Python backend

While slower than specialized C/C++ implementations, the implementation is general and works with any exact field in Sage that allows you to define polyhedra.

EXAMPLES:

sage: # needs sage.rings.number_field
sage: p0 = (0, 0)
sage: p1 = (1, 0)
sage: p2 = (1/2, AA(3).sqrt()/2)
sage: equilateral_triangle = Polyhedron([p0, p1, p2])
sage: equilateral_triangle.vertices()
(A vertex at (0, 0),
 A vertex at (1, 0),
 A vertex at (0.500000000000000?, 0.866025403784439?))
sage: equilateral_triangle.inequalities()
(An inequality (-1, -0.5773502691896258?) x + 1 >= 0,
 An inequality (1, -0.5773502691896258?) x + 0 >= 0,
 An inequality (0, 1.154700538379252?) x + 0 >= 0)
>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> p0 = (Integer(0), Integer(0))
>>> p1 = (Integer(1), Integer(0))
>>> p2 = (Integer(1)/Integer(2), AA(Integer(3)).sqrt()/Integer(2))
>>> equilateral_triangle = Polyhedron([p0, p1, p2])
>>> equilateral_triangle.vertices()
(A vertex at (0, 0),
 A vertex at (1, 0),
 A vertex at (0.500000000000000?, 0.866025403784439?))
>>> equilateral_triangle.inequalities()
(An inequality (-1, -0.5773502691896258?) x + 1 >= 0,
 An inequality (1, -0.5773502691896258?) x + 0 >= 0,
 An inequality (0, 1.154700538379252?) x + 0 >= 0)
class sage.geometry.polyhedron.backend_field.Polyhedron_field(parent, Vrep, Hrep, Vrep_minimal=None, Hrep_minimal=None, pref_rep=None, mutable=False, **kwds)[source]

Bases: Polyhedron_base

Polyhedra over all fields supported by Sage.

INPUT:

  • Vrep – list [vertices, rays, lines] or None

  • Hrep – list [ieqs, eqns] or None

EXAMPLES:

sage: p = Polyhedron(vertices=[(0,0),(AA(2).sqrt(),0),(0,AA(3).sqrt())],        # needs sage.rings.number_field
....:                rays=[(1,1)], lines=[], backend='field', base_ring=AA)
sage: TestSuite(p).run()                                                        # needs sage.rings.number_field
>>> from sage.all import *
>>> p = Polyhedron(vertices=[(Integer(0),Integer(0)),(AA(Integer(2)).sqrt(),Integer(0)),(Integer(0),AA(Integer(3)).sqrt())],        # needs sage.rings.number_field
...                rays=[(Integer(1),Integer(1))], lines=[], backend='field', base_ring=AA)
>>> TestSuite(p).run()                                                        # needs sage.rings.number_field