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

Commit

Permalink
do not delete columns if we do not have to
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jun 17, 2020
1 parent 527316d commit 2db3a70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Expand Up @@ -349,6 +349,8 @@ cdef class CombinatorialPolyhedron(SageObject):
# ``self._length_edges_list*2*sizeof(size_t *)``.
self._length_edges_list = 16348

data_modified = None

if isinstance(data, Polyhedron_base):
# input is ``Polyhedron``
Vrep = data.Vrepresentation()
Expand All @@ -361,7 +363,14 @@ cdef class CombinatorialPolyhedron(SageObject):
else:
self._bounded = True

P = data
data = data.incidence_matrix()

# Delete equations
if P.n_equations():
data_modified = data.delete_columns([e.index() for e in P.equations()])
else:
data_modified = data
elif isinstance(data, LatticePolytopeClass):
# input is ``LatticePolytope``
self._bounded = True
Expand Down Expand Up @@ -440,8 +449,10 @@ cdef class CombinatorialPolyhedron(SageObject):
data.set_immutable()
self.incidence_matrix.set_cache(data)

# Delete equations.
data_modified = data.delete_columns([i for i in range(data.ncols()) if all(data[j,i] for j in range(data.nrows()))], check=False)

if data_modified is None:
# Delete equations.
data_modified = data.delete_columns([i for i in range(data.ncols()) if all(data[j,i] for j in range(data.nrows()))], check=False)

# Initializing the facets in their Bit-representation.
self._bitrep_facets = incidence_matrix_to_bit_rep_of_facets(data_modified)
Expand Down
Expand Up @@ -318,7 +318,7 @@ def incidence_matrix_to_bit_rep_of_facets(Matrix_integer_dense matrix):
# Filling each facet with its Vrep-incidences, which "is" the
# "i-th column" of the original matrix (but we have transposed).
for entry in range(nrows):
if matrix.get_unsafe_double(entry, i):
if not matrix.get_is_zero_unsafe(entry, i):
# Vrep ``entry`` is contained in the face, so set the corresponding bit
value = entry % 64
position = entry//64
Expand Down

0 comments on commit 2db3a70

Please sign in to comment.