Ticket #22455: facet-adjacency-fix.patch

File facet-adjacency-fix.patch, 1.2 KB (added by Christoph Pegel, 6 years ago)

proposed patch

  • sage/geometry/polyhedron/base.py

    diff -Naur a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
    a b  
    272272        """
    273273        # TODO: This implementation computes the whole face lattice,
    274274        # which is much more information than necessary.
    275         M = matrix(ZZ, self.n_Hrepresentation(), self.n_Hrepresentation(), 0)
     275        M = matrix(ZZ, self.n_facets(), self.n_facets(), 0)
     276        codim = self.ambient_dim()-self.dim()
    276277        def set_adjacent(h1,h2):
    277278            if h1 is h2:
    278279                return
    279             i = h1.index()
    280             j = h2.index()
     280            i = h1.index() - codim
     281            j = h2.index() - codim
    281282            M[i,j]=1
    282283            M[j,i]=1
    283284
    284         face_lattice = self.face_lattice()
    285         for face in face_lattice:
     285        for face in self.faces(self.dim()-2):
    286286            Hrep = face.ambient_Hrepresentation()
    287             if len(Hrep) == 2:
    288                 set_adjacent(Hrep[0], Hrep[1])
     287            assert(len(Hrep) == codim+2)
     288            set_adjacent(Hrep[-2], Hrep[-1])
    289289        return M
    290290
    291291    def _vertex_adjacency_matrix(self):