Conversions#

This module provides conversions to ListOfFaces from - an incidence matrix of a polyhedron or - a tuple of facets (as tuple of vertices each).

Also this module provides a conversion from the data of ListOfFaces, which is a Bit-vector representing incidences of a face, to a list of entries which are incident.

EXAMPLES:

Obtain the facets of a polyhedron as ListOfFaces:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:         import incidence_matrix_to_bit_rep_of_facets
sage: P = polytopes.simplex(4)
sage: inc = P.incidence_matrix()
sage: mod_inc = inc.delete_columns([i for i,V in enumerate(P.Hrepresentation()) if V.is_equation()])
sage: face_list = incidence_matrix_to_bit_rep_of_facets(mod_inc)
sage: face_list.compute_dimension()
4

Obtain the Vrepresentation of a polyhedron as facet-incidences stored in ListOfFaces:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:         import incidence_matrix_to_bit_rep_of_Vrep
sage: P = polytopes.associahedron(['A',4])                                   # optional - sage.combinat
sage: face_list = incidence_matrix_to_bit_rep_of_Vrep(P.incidence_matrix())  # optional - sage.combinat
sage: face_list.compute_dimension()                                          # optional - sage.combinat
4

Obtain the facets of a polyhedron as ListOfFaces from a facet list:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:         import facets_tuple_to_bit_rep_of_facets
sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3))
sage: face_list = facets_tuple_to_bit_rep_of_facets(facets, 4)

Likewise for the Vrep as facet-incidences:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:         import facets_tuple_to_bit_rep_of_Vrep
sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3))
sage: face_list = facets_tuple_to_bit_rep_of_Vrep(facets, 4)

AUTHOR:

  • Jonathan Kliem (2019-04)

sage.geometry.polyhedron.combinatorial_polyhedron.conversions.facets_tuple_to_bit_rep_of_Vrep(facets_input, n_Vrep)#

Initialize Vrepresentatives in Bit-representation as ListOfFaces.

Each Vrepresentative is represented as the facets it is contained in. Those are the facets of the polar polyhedron, if it exists.

INPUT:

  • facets_input – tuple of facets, each facet a tuple of Vrep, Vrep must be exactly range(n_Vrep)

  • n_Vrep

OUTPUT:

EXAMPLES:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:     import facets_tuple_to_bit_rep_of_Vrep, \
....:            _bit_rep_to_Vrep_list_wrapper
sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4),
....:           (0,1,5), (1,2,5), (2,3,5), (3,0,5))
sage: vertices = facets_tuple_to_bit_rep_of_Vrep(bi_pyr, 6)
sage: for i in range(6):
....:     print(_bit_rep_to_Vrep_list_wrapper(vertices, i))
(0, 3, 4, 7)
(0, 1, 4, 5)
(1, 2, 5, 6)
(2, 3, 6, 7)
(0, 1, 2, 3)
(4, 5, 6, 7)
sage.geometry.polyhedron.combinatorial_polyhedron.conversions.facets_tuple_to_bit_rep_of_facets(facets_input, n_Vrep)#

Initializes facets in Bit-representation as ListOfFaces.

INPUT:

  • facets_input – tuple of facets, each facet a tuple of Vrep, Vrep must be exactly range(n_Vrep)

  • n_Vrep

OUTPUT:

EXAMPLES:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:     import facets_tuple_to_bit_rep_of_facets, \
....:            _bit_rep_to_Vrep_list_wrapper
sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4),
....:           (0,1,5), (1,2,5), (2,3,5), (3,0,5))
sage: facets = facets_tuple_to_bit_rep_of_facets(bi_pyr, 6)
sage: for i in range(8):
....:     print(_bit_rep_to_Vrep_list_wrapper(facets, i))
(0, 1, 4)
(1, 2, 4)
(2, 3, 4)
(0, 3, 4)
(0, 1, 5)
(1, 2, 5)
(2, 3, 5)
(0, 3, 5)
sage.geometry.polyhedron.combinatorial_polyhedron.conversions.incidence_matrix_to_bit_rep_of_Vrep(matrix)#

Initialize Vrepresentatives in Bit-representation as ListOfFaces.

Each Vrepresentative is represented as the facets it is contained in. Those are the facets of the polar polyhedron, if it exists.

INPUT:

  • matrix – an incidence matrix as in sage.geometry.polyhedron.base.Polyhedron_base.incidence_matrix() with columns corresponding to equations deleted of type sage.matrix.matrix_dense.Matrix_dense

OUTPUT:

EXAMPLES:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:     import incidence_matrix_to_bit_rep_of_Vrep, \
....:            _bit_rep_to_Vrep_list_wrapper
sage: P = polytopes.permutahedron(4)
sage: inc = P.incidence_matrix()
sage: mod_inc = inc.delete_columns([i for i,V in enumerate(P.Hrepresentation()) if V.is_equation()])
sage: vertices = incidence_matrix_to_bit_rep_of_Vrep(mod_inc)
sage: vertices.matrix().dimensions()
(24, 14)
sage: for row in vertices.matrix():
....:     row.nonzero_positions()
[8, 9, 11]
[8, 10, 11]
[2, 3, 7]
[1, 5, 7]
[4, 5, 7]
[1, 3, 7]
[4, 6, 7]
[2, 6, 7]
[1, 5, 13]
[8, 9, 13]
[1, 9, 11]
[2, 10, 11]
[1, 3, 11]
[2, 3, 11]
[4, 5, 13]
[4, 12, 13]
[8, 12, 13]
[1, 9, 13]
[0, 8, 12]
[0, 4, 12]
[0, 2, 10]
[0, 2, 6]
[0, 8, 10]
[0, 4, 6]
sage.geometry.polyhedron.combinatorial_polyhedron.conversions.incidence_matrix_to_bit_rep_of_facets(matrix)#

Initialize facets in Bit-representation as ListOfFaces.

INPUT:

  • matrix – an incidence matrix as in sage.geometry.polyhedron.base.Polyhedron_base.incidence_matrix() with columns corresponding to equations deleted of type sage.matrix.matrix_dense.Matrix_dense

OUTPUT:

EXAMPLES:

sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \
....:     import incidence_matrix_to_bit_rep_of_facets, \
....:            _bit_rep_to_Vrep_list_wrapper
sage: P = polytopes.permutahedron(4)
sage: inc = P.incidence_matrix()
sage: mod_inc = inc.delete_columns([i for i,V in enumerate(P.Hrepresentation()) if V.is_equation()])
sage: facets = incidence_matrix_to_bit_rep_of_facets(mod_inc)
sage: facets.matrix().dimensions()
(14, 24)
sage: for row in facets.matrix():
....:     row.nonzero_positions()
[18, 19, 20, 21, 22, 23]
[3, 5, 8, 10, 12, 17]
[2, 7, 11, 13, 20, 21]
[2, 5, 12, 13]
[4, 6, 14, 15, 19, 23]
[3, 4, 8, 14]
[6, 7, 21, 23]
[2, 3, 4, 5, 6, 7]
[0, 1, 9, 16, 18, 22]
[0, 9, 10, 17]
[1, 11, 20, 22]
[0, 1, 10, 11, 12, 13]
[15, 16, 18, 19]
[8, 9, 14, 15, 16, 17]