This repository was archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
.. -*- coding: utf-8 -*- | ||
.. linkall | ||
.. _tips: | ||
|
||
============================================================== | ||
Tips, Tricks and Good Things to Know | ||
============================================================== | ||
|
||
.. MODULEAUTHOR:: Jean-Philippe Labbé <[email protected]> | ||
|
||
|
||
Sage input function | ||
============================================================== | ||
|
||
If you are working with a polyhedron that was difficult to construct | ||
and you would like to get back the proper Sage input code to reproduce this | ||
object, you can! | ||
|
||
:: | ||
|
||
sage: Cube = polytopes.cube() | ||
sage: TCube = Cube.truncation() | ||
sage: sage_input(TCube) | ||
Polyhedron(base_ring=QQ, vertices=[(-QQ(1), -QQ(1), -1/3), (-QQ(1), -QQ(1), | ||
1/3), (-QQ(1), -1/3, -QQ(1)), (-QQ(1), -1/3, QQ(1)), (-QQ(1), 1/3, -QQ(1)), | ||
(-QQ(1), 1/3, QQ(1)), (-QQ(1), QQ(1), -1/3), (-QQ(1), QQ(1), 1/3), (-1/3, | ||
-QQ(1), -QQ(1)), (-1/3, -QQ(1), QQ(1)), (-1/3, QQ(1), -QQ(1)), (-1/3, | ||
QQ(1), QQ(1)), (1/3, -QQ(1), -QQ(1)), (1/3, -QQ(1), QQ(1)), (1/3, QQ(1), | ||
-QQ(1)), (1/3, QQ(1), QQ(1)), (QQ(1), -QQ(1), -1/3), (QQ(1), -QQ(1), 1/3), | ||
(QQ(1), -1/3, -QQ(1)), (QQ(1), -1/3, QQ(1)), (QQ(1), 1/3, -QQ(1)), (QQ(1), | ||
1/3, QQ(1)), (QQ(1), QQ(1), -1/3), (QQ(1), QQ(1), 1/3)]) | ||
|
||
.. end of output | ||
:code:`repr_pretty_Hrepresentation` | ||
============================================================== | ||
|
||
If you would like to visualize the :math:`H`-representation nicely and even get | ||
the latex presentation, there is a method for that! | ||
|
||
:: | ||
|
||
sage: Nice_repr = TCube.repr_pretty_Hrepresentation(separator='\n') | ||
sage: print Nice_repr | ||
1 >= x0 | ||
1 >= x1 | ||
3*x1 + 7 >= 3*x0 + 3*x2 | ||
x0 + 1 >= 0 | ||
x1 + 1 >= 0 | ||
3*x0 + 7 >= 3*x1 + 3*x2 | ||
3*x0 + 3*x1 + 7 >= 3*x2 | ||
3*x0 + 3*x2 + 7 >= 3*x1 | ||
3*x0 + 3*x1 + 3*x2 + 7 >= 0 | ||
x2 + 1 >= 0 | ||
1 >= x2 | ||
3*x1 + 3*x2 + 7 >= 3*x0 | ||
3*x2 + 7 >= 3*x0 + 3*x1 | ||
7 >= 3*x0 + 3*x1 + 3*x2 | ||
|
||
sage: Latex_repr = LatexExpr(TCube.repr_pretty_Hrepresentation(separator=",\\\\", latex=True)) | ||
sage: view(Latex_repr) # not tested | ||
|
||
.. end of output |