Opened 2 years ago

Closed 2 years ago

# #29843 introduces a bug in Polyhedron().linear_transformation

Reported by: Owned by: etn40ff critical sage-9.2 geometry combinatorial polyhedron, linear transformation jipilab, gh-LaisRast, gh-kliem, mkoeppe Jonathan Kliem Matthias Koeppe N/A c9c7b63 c9c7b63f1ed9fda028044385920f2b7849cfbd2b

### Description

In 9.2.beta5 applying linear transformations to a polyhedron containing a ray is broken:

```sage: Polyhedron(rays=[(0,1)]).linear_transformation(identity_matrix(2))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-185-3c5f2df4fe7c> in <module>()
----> 1 Polyhedron(rays=[(Integer(0),Integer(1))]).linear_transformation(identity_matrix(Integer(2)))

/opt/sage/sage/local/lib/python3.7/site-packages/sage/geometry/polyhedron/base.py in linear_transformation(self, linear_transf, new_base_ring)
5093
5094             sage: P = Polyhedron([(0,0),(1,1)], base_ring=ZZ)
-> 5095             sage: P.intersection(P)
5096             A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
5097             sage: Q = Polyhedron([(0,1),(1,0)], base_ring=ZZ)

/opt/sage/sage/local/lib/python3.7/site-packages/sage/geometry/polyhedron/base.py in __init__(self, parent, Vrep, Hrep, Vrep_minimal, Hrep_minimal, pref_rep, **kwds)
218         # TODO: find something better *but* fast
219         return hash((self.dim(),
--> 220                      self.ambient_dim(),
221                      self.n_Hrepresentation(),
222                      self.n_Vrepresentation(),

/opt/sage/sage/local/lib/python3.7/site-packages/sage/geometry/polyhedron/backend_ppl.py in _init_from_Vrepresentation(self, vertices, rays, lines, minimize, verbose)
75             d = LCM_list([denominator(r_i) for r_i in r])
76             if d.is_one():
---> 77                 gs.insert(ray(Linear_Expression(r, 0)))
78             else:
79                 dr = [ d*r_i for r_i in r ]

ppl/generator.pyx in ppl.generator.Generator.ray()

ppl/generator.pyx in ppl.generator.Generator.ray()

ValueError: PPL::ray(e):
e == 0, but the origin cannot be a ray.
```

this used to work just fine in 9.2.beta4.

`git bisect` seems to blame the regression on #29843

### comment:1 Changed 2 years ago by mkoeppe

• Priority changed from major to critical

### comment:2 Changed 2 years ago by gh-kliem

Thanks for catching this. This is another friendly reminder that working on those test suites is really useful.

Last edited 2 years ago by gh-kliem (previous) (diff)

### comment:3 Changed 2 years ago by gh-kliem

• Authors set to Jonathan Kliem
• Branch set to public/30146
• Commit set to 4eff4137dfac9c656bb8e50343be76efae2974ae
• Status changed from new to needs_review

New commits:

 ​07e4ab1 `fix bog introduced by 39843` ​4eff413 `add tiny testsuite to doctest`

### comment:4 follow-up: ↓ 5 Changed 2 years ago by git

• Commit changed from 4eff4137dfac9c656bb8e50343be76efae2974ae to 7fe6b43d2ab3adde507fe745726b82c3bbc8059d

Branch pushed to git repo; I updated commit sha1. New commits:

 ​7fe6b43 `One transposition only`

### comment:5 in reply to: ↑ 4 Changed 2 years ago by gh-kliem

Branch pushed to git repo; I updated commit sha1. New commits:

 ​7fe6b43 `One transposition only`

I was thinking about that one. At first glance this might be a bit weird, because the matrix is supposed to act from the left. However it is shorter and easier to read I guess (and slightly faster I suppose).

### comment:6 Changed 2 years ago by git

• Commit changed from 7fe6b43d2ab3adde507fe745726b82c3bbc8059d to c9c7b63f1ed9fda028044385920f2b7849cfbd2b

Branch pushed to git repo; I updated commit sha1. New commits:

 ​c9c7b63 `missed preceeding `sage:` of doctests`

### comment:7 Changed 2 years ago by mkoeppe

• Reviewers set to Matthias Koeppe
• Status changed from needs_review to positive_review

Thank you.

### comment:9 Changed 2 years ago by vbraun

• Branch changed from public/30146 to c9c7b63f1ed9fda028044385920f2b7849cfbd2b
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.