Page 2 of 2
Re: QuadraticExtension in Polymake 3.0
Posted: 31 Jan 2016, 21:28
by joswig
The code you are listing interfaces to the Parma Polyhedra Library (ppl). However, ppl (which is an independent software project) does not support other coordinates than rational numbers. The only convex hull algorithm available from within polymake which can use (suitably adapted) field coefficients is polymake's own beneath_beyond.
Re: QuadraticExtension in Polymake 3.0
Posted: 01 Feb 2016, 10:58
by mws
Ok, I see. Then I have three questions:
- How exactly do I use beneath-beyond with the callable library? Could someone maybe provide a minimal working example?
- Does it use Perl in any way? I am just asking because I would like to avoid since it slows down computations greatly in my experience.
- What exactly do you mean by "suitably adapted"? Just that all coordinates have to come from the same quadratic extension?
Thanks!
Re: QuadraticExtension in Polymake 3.0
Posted: 01 Feb 2016, 12:57
by blorenz
A short example to use beneath_beyond from C++ code without using any perl (apart from the generation of the input data):
Code: Select all
#include <polymake/polytope/beneath_beyond.h>
...
// create some input data
perl::Object p = CallPolymakeFunction("johnson_solid",91);
Matrix<QuadraticExtension<Rational> > V = p.give("VERTICES");
// the 'true' at the end tells the algorithm that the input points are already vertices
// in general you probably want 'false' there
polytope::beneath_beyond_algo<QuadraticExtension<Rational> > algo(V,true);
// the (end-sensitive) iterator specifies the insertion order of the points
algo.compute(entire(sequence(0,V.rows())));
Matrix<QuadraticExtension<Rational> > F = algo.getFacets();
For QuadraticExtension it suffices that all coordinates are from the same one. The suitably adapted remark probably refers to the fact that the beneath and beyond implementation also supports other field types as long as they satisfy some conditions on the available operators / methods.
Best,
Benjamin
Re: QuadraticExtension in Polymake 3.0
Posted: 01 Feb 2016, 21:48
by mws
Dear Benjamin,
Thanks for your helpful reply. Since my polytopes are defined via hyperplanes and not points, I looked at beneath_beyond.h to find the appropriate constructor. Unfortunately I couldn't find anything. However, I guess that I am missing something... So can you maybe tell me how to you use Polymake's beneath beyond algorithm with hyperplanes?
Thanks,
Moritz
Re: QuadraticExtension in Polymake 3.0
Posted: 01 Feb 2016, 22:28
by gawrilow
Exactly the same: call it with a matrix with inequalities and a boolean flag indicating whether they are known to be facets, that is, complete and not redundant. Then Facets() will in fact deliver the vertices. Just have a look into apps/polytope/src/beneath_beyond.cc, the code is pretty much self-explanatory for those familiar with polymake basics (and you seem to be far above that level).
Re: QuadraticExtension in Polymake 3.0
Posted: 02 Feb 2016, 12:39
by mws
Just to make sure that I understand your answer correctly: You suggest to use something like
Code: Select all
polymake::polytope::beneath_beyond_algo<polymake::QuadraticExtension<polymake::Rational>> algo(H, false);
algo.compute(polymake::entire(polymake::sequence(0, H.rows())));
polymake::Matrix<polymake::QuadraticExtension<polymake::Rational> > V = algo.getVertices();
with H being a matrix of type polymake::Matrix<QuadraticExtension<polymake::Rational>> containing my (affine, not necessarily facet defining) hyperplanes. This should compute the vertices of the polytope defined by H, right?
And your hint to look at beneath_beyond.cc was just for me to learn about the different method names to compute stuff -- Это верно?
I am just being so insistent because the above code yields a segfault for me.
Re: QuadraticExtension in Polymake 3.0
Posted: 02 Feb 2016, 15:02
by gawrilow
Your use case exactly corresponds to the dual mode of beneath_beyond client. getVertices() would give you the facets of your polyhedron, and getFacets() would give you the vertices.
Regarding the segfault: could you please feed your inequalities into polymake via callable library methods:
Code: Select all
perl::Main pmain;
pmain.set_application("polytope");
Matrix< QuadraticExtension<Rational> > H(...);
perl::Object poly("Polytope<QuadraticExtension<Rational>>");
poly.take("INEQUALITIES") << H;
perl::Scope psc=pmain.newScope();
psc.prefer_now("beneath_beyond");
Matrix< QuadraticExtension<Rational> > V = poly.give("VERTICES");
cout << V;
It's advisable to build this program in debug mode first (make Debug=y); it will activate various sanity checks.
Re: QuadraticExtension in Polymake 3.0
Posted: 03 Feb 2016, 22:22
by mws
Ok, I finally understood the segfaults. They seem to have occured because I used
Code: Select all
polymake::Main pm;
pm.set_application("polytope");
too late in my code.
Thanks to all who have taken the time to contribute to this thread -- you have helped me a great deal!