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: p0 = (0, 0)
sage: p1 = (1, 0)
sage: p2 = (1/2, AA(3).sqrt()/2)                                            # optional - sage.rings.number_field
sage: equilateral_triangle = Polyhedron([p0, p1, p2])                       # optional - sage.rings.number_field
sage: equilateral_triangle.vertices()                                       # optional - sage.rings.number_field
(A vertex at (0, 0),
 A vertex at (1, 0),
 A vertex at (0.500000000000000?, 0.866025403784439?))
sage: equilateral_triangle.inequalities()                                   # optional - sage.rings.number_field
(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)#

Bases: Polyhedron_base

Polyhedra over all fields supported by Sage

INPUT:

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

  • Hrep – a list [ieqs, eqns] or None.

EXAMPLES:

sage: p = Polyhedron(vertices=[(0,0),(AA(2).sqrt(),0),(0,AA(3).sqrt())],    # optional - sage.rings.number_field
....:                rays=[(1,1)], lines=[], backend='field', base_ring=AA)
sage: TestSuite(p).run()                                                    # optional - sage.rings.number_field