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

Commit a1072ee

Browse files
author
Jonathan Kliem
committed
give a error message if self on left; better error check for zero_matrix
1 parent 7a694a0 commit a1072ee

File tree

1 file changed

+11
-3
lines changed
  • src/sage/geometry/polyhedron

1 file changed

+11
-3
lines changed

src/sage/geometry/polyhedron/base.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4330,8 +4330,14 @@ def linear_transformation(self, linear_transf):
43304330
Traceback (most recent call last):
43314331
...
43324332
TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 1 by 8 dense matrices over Integer Ring' and 'Ambient free module of rank 9 over the principal ideal domain Integer Ring'
4333+
sage: Matrix(ZZ, []) * b3
4334+
A 0-dimensional polyhedron in ZZ^0 defined as the convex hull of 1 vertex
4335+
sage: Matrix(ZZ, [[],[]]) * b3
4336+
Traceback (most recent call last):
4337+
...
4338+
TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 2 by 0 dense matrices over Integer Ring' and 'Ambient free module of rank 9 over the principal ideal domain Integer Ring'
43334339
"""
4334-
if linear_transf.ncols() != 0:
4340+
if linear_transf.nrows() != 0:
43354341
new_vertices = [ list(linear_transf*v.vector()) for v in self.vertex_generator() ]
43364342
new_rays = [ list(linear_transf*r.vector()) for r in self.ray_generator() ]
43374343
new_lines = [ list(linear_transf*l.vector()) for l in self.line_generator() ]
@@ -4397,14 +4403,16 @@ def _acted_upon_(self, actor, self_on_left):
43974403
sage: p * matrix(ZZ, [[1,2,3]]*3)
43984404
Traceback (most recent call last):
43994405
...
4400-
TypeError: unsupported operand parent(s) for *: 'Polyhedra in ZZ^3' and 'Full MatrixSpace of 3 by 3 dense matrices over Integer Ring'
4406+
ValueError: matrices should act on the left
44014407
"""
44024408
if is_Polyhedron(actor):
44034409
return self.product(actor)
44044410
elif is_Vector(actor):
44054411
return self.translation(actor)
44064412
elif is_Matrix(actor):
4407-
if not self_on_left:
4413+
if self_on_left:
4414+
raise ValueError("matrices should act on the left")
4415+
else:
44084416
return self.linear_transformation(actor)
44094417
else:
44104418
return self.dilation(actor)

0 commit comments

Comments
 (0)