Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
store incidence matrix, if initialized from it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Apr 24, 2020
1 parent 249fc90 commit 5d1a52e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ cdef class CombinatorialPolyhedron(SageObject):
self._n_Hrepresentation = data.ncols()
self._n_Vrepresentation = data.nrows()

# Store the incidence matrix.
if not data.is_immutable():
data = data.__copy__()
data.set_immutable()
self.incidence_matrix.set_cache(data)

# Initializing the facets in their Bit-representation.
self._bitrep_facets = incidence_matrix_to_bit_rep_of_facets(data)

Expand Down Expand Up @@ -984,11 +990,22 @@ cdef class CombinatorialPolyhedron(SageObject):
[0 0 0 1 1 1]
[0 1 0 1 1 0]
[0 1 1 1 0 0]
sage: P.incidence_matrix() == C.incidence_matrix()
In this case the incidence matrix is only computed once::
sage: P.incidence_matrix() is C.incidence_matrix()
True
sage: C.incidence_matrix.clear_cache()
sage: C.incidence_matrix() is P.incidence_matrix()
False
sage: C.incidence_matrix() == P.incidence_matrix()
True
::
sage: P = polytopes.permutahedron(5)
sage: C = P.combinatorial_polyhedron()
sage: C.incidence_matrix.clear_cache()
sage: C.incidence_matrix() == P.incidence_matrix()
True
Expand All @@ -998,6 +1015,8 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: P = Polyhedron([[0,0]])
sage: P.incidence_matrix()
[1 1]
sage: C = P.combinatorial_polyhedron()
sage: C.incidence_matrix.clear_cache()
sage: P.combinatorial_polyhedron().incidence_matrix()
[1 1]
Expand All @@ -1006,9 +1025,11 @@ cdef class CombinatorialPolyhedron(SageObject):
Check that :trac:`29455` is fixed::
sage: C = Polyhedron([[0]]).combinatorial_polyhedron()
sage: C.incidence_matrix.clear_cache()
sage: C.incidence_matrix()
[1]
sage: C = CombinatorialPolyhedron(-1)
sage: C.incidence_matrix.clear_cache()
sage: C.incidence_matrix()
[]
"""
Expand Down

0 comments on commit 5d1a52e

Please sign in to comment.