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)
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)
class sage.geometry.polyhedron.backend_field.Polyhedron_field(parent, Vrep, Hrep, **kwds)

Bases: sage.geometry.polyhedron.base.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())],
....:                rays=[(1,1)], lines=[], backend='field', base_ring=AA)
sage: TestSuite(p).run()

TESTS:

sage: K.<sqrt3> = NumberField(x^2-3)
sage: p = Polyhedron([(0,0), (1,0), (1/2, sqrt3/2)])
sage: TestSuite(p).run()

Check that trac ticket #19013 is fixed:

sage: K.<phi> = NumberField(x^2-x-1, embedding=1.618)
sage: P1 = Polyhedron([[0,1],[1,1],[1,-phi+1]])
sage: P2 = Polyhedron(ieqs=[[-1,-phi,0]])
sage: P1.intersection(P2)
The empty polyhedron in (Number Field in phi with defining polynomial
x^2 - x - 1)^2