Ask Your Question
0

Extraction of a result in an other form

asked 2019-10-02 23:36:04 +0200

Cyrille gravatar image

For the following code

pol = Polyhedron(ieqs = [[5, -1/2, -1/4],[-18, 1, 3],[0, 1, 0],  [0, 0, 1]])

vr=pol.Vrepresentation()

vr

the result is

(A vertex at (0, 20), A vertex at (42/5, 16/5), A vertex at (0, 6))

How to have it as

pol= [(0, 20),(42/5, 16/5),(0, 6)] ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-02 23:56:06 +0200

tmonteil gravatar image

As you can see, the returned elements are vertices, with their own methods, like the ability to provide its neighbors in the polyhedron.

sage: v = vr[0]
sage: v
A vertex at (0, 20)
sage: type(v)
<class 'sage.geometry.polyhedron.representation.Vertex'>

You can transform a vertex into a tuple as follows:

sage: tuple(v)
(0, 20)

So, to do that for each element of the list, you can just use list comprehension:

sage: [tuple(v) for v in vr]
[(0, 20), (42/5, 16/5), (0, 6)]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-10-02 23:36:04 +0200

Seen: 122 times

Last updated: Oct 02 '19