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

Commit

Permalink
temporary fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jan 31, 2020
1 parent 4fb0f6b commit 3f6013b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8589,13 +8589,11 @@ def affine_hull(self, as_affine_map=False, orthogonal=False, orthonormal=False,
# see TODO
if not self.is_compact():
raise NotImplementedError('"orthogonal=True" and "orthonormal=True" work only for compact polyhedra')
# translate 0th vertex to the origin
Q = self.translation(-vector(self.vertices()[0]))
v = next((_ for _ in Q.vertices() if _.vector() == Q.ambient_space().zero()), None)
# finding the zero in Q; checking that Q actually has a vertex zero
assert v.vector() == Q.ambient_space().zero()
# choose as an affine basis the neighbors of the origin vertex in Q
M = matrix(self.base_ring(), self.dim(), self.ambient_dim(), [list(w) for w in itertools.islice(v.neighbors(), self.dim())])
affine_basis = self.an_affine_basis()
# We implicitely translate the first vertex of the affine basis to zero.
M = matrix(self.base_ring(), self.dim(), self.ambient_dim(),
[v.vector() - affine_basis[0].vector() for v in affine_basis[1:]])

# Switch base_ring to AA if necessary,
# since gram_schmidt needs to be able to take square roots.
# Pick orthonormal basis and transform all vertices accordingly
Expand All @@ -8608,9 +8606,11 @@ def affine_hull(self, as_affine_map=False, orthogonal=False, orthonormal=False,
M = matrix(AA, M)
A = M.gram_schmidt(orthonormal=orthonormal)[0]
if as_affine_map:
return linear_transformation(A, side='right'), -A*vector(A.base_ring(), self.vertices()[0])
return linear_transformation(A, side='right'), -A*vector(A.base_ring(), affine_basis[0])

translate_vector = vector(A.base_ring(), affine_basis[0])
parent = self.parent().change_ring(A.base_ring(), ambient_dim=self.dim())
new_vertices = [A*vector(A.base_ring(), w) for w in Q.vertices()]
new_vertices = [A*(vector(A.base_ring(), w) - translate_vector) for w in self.vertices()]
return parent.element_class(parent, [new_vertices, [], []], None)

# translate one vertex to the origin
Expand Down

0 comments on commit 3f6013b

Please sign in to comment.