triangulation gone wrong?

Questions and problems about using polymake go here.
HPollehn
Posts: 2
Joined: 03 Oct 2013, 11:52

triangulation gone wrong?

Postby HPollehn » 03 Oct 2013, 12:04

Hello there,

I'm new to polymake and I'm currently trying to learn general commands and syntax of polymake. At one point I tried to compute a triangulation of a cube with dimension 3. I use the commands:

Code: Select all

$p=cube(3); $tri=$p->TRIANGULATION; print $tri->FACETS;
The curious thing is when I print the vertices of $p first, then the triangulation fails.

Why is that? And is this the proper way to compute a triangulation in polymake?

Best regards
Hannes Pollehn
Attachments
triangulation gone wrong.jpg
(55.94 KiB) Downloaded 2076 times

paffenholz
Developer
Posts: 211
Joined: 24 Dec 2010, 13:47

Re: triangulation gone wrong?

Postby paffenholz » 04 Oct 2013, 09:49

The curious thing is when I print the vertices of $p first, then the triangulation fails.

Why is that?
This behavior is a side effect of the current rules implemented for triangulations, but certainly not the intended behavior. Whenever you assign a triangulation coming from a polytope $c to a separate variable $t=$c->TRIAGULATION, the polytope and this triangulation share the same properties (they share the same object in memory, i.e. $t is a pointer to the triangulation in $c).

Unfortunately, in your second example the triangulation is only created temporarily, as it is created via a rule that says that the coordinates of the triangulation are the vertices of the polytope, and those should not be stored twice. So when the assignment has finished, the triangulation is removed from the cube, leaving you with a rather useless pointer $tri. In the first case everything is fine as polymake choses a rule that computes the facets of the triangulation, and those are stored permanently.

We are currently working on a redesing of triangulations, and this should fix this problem. The quick and simple workaround till then is to ask for a permanent property before assigning the triangulation to a variable. This could e.g. be BALL or FACETS, i.e.

Code: Select all

$c=cube(3); $c->VERTICES; $c->TRIANGULATION->FACETS; $t=$c->TRIANGULATION;
You can also just work with the polytope, accessing properties of the triangulation via $c->TRIANGULATION-><property>.
And is this the proper way to compute a triangulation in polymake?
That depends. If you just need some triangulation of the object then this is the way to go. TRIANGULATION will just contain some arbitrary triangulation on the vertices. If you need more control then you should look into point configuration (created via the object PointConfiguration) and regular subdivisions (see e.g. here).

HPollehn
Posts: 2
Joined: 03 Oct 2013, 11:52

Re: triangulation gone wrong?

Postby HPollehn » 04 Oct 2013, 16:58

Thanks for your answer. Actually I'm trying to write C++ program which uses the triangulation from polymake via the callable library. I have figured out how I can get the properties of an object, for example the vertices

Code: Select all

perl::Object p("Polytope<Rational>"); ... p.give("VERTICES");
How is the command p->TRIANGULATION->FACETS translated to the C++ interface?

My initial guesses failed.

Code: Select all

Matrix<Rational> tri = (p.give("TRIANGULATION")).give("FACETS"); // because the triangulation is from the class perl::PropertyValue perl::Object sp("SimplicialComplex<Rational>"); sp = p.give("TRIANGULATION"); // runtime error. polymake doesn't know a class with that name

paffenholz
Developer
Posts: 211
Joined: 24 Dec 2010, 13:47

Re: triangulation gone wrong?

Postby paffenholz » 08 Oct 2013, 00:53

In C++-code you have to use "dot notation" to access subproperties, like

Code: Select all

P.give("TRIANGULATION.FACETS")
For general syntax in C++-code you can check
http://www.polymake.org/doku.php/reference/clients
or look into some of the C++-files in apps/polytope/src in the polymake root folder.

Andreas


Return to “Helpdesk”