barvinok 0.41.7
[barvinok.git] / polymake / lattice_points.cc
blob3b75e826747b210670ded4842b300077bb65de76
1 #include <gmp.h>
2 #include <cstdlib>
3 #include <Rational.h>
4 #include <Poly.h>
5 #include <Matrix.h>
6 #include <barvinok/barvinok.h>
7 #include "convert.h"
9 namespace polymake { namespace polytope {
11 void lattice_points(Poly& p)
13 Value cb;
14 Matrix<Rational> F = p.give("FACETS | INEQUALITIES");
15 ::Matrix *M = polymake_constraints2polylib(F);
16 Polyhedron *A = Constraints2Polyhedron(M, 0);
17 Matrix_Free(M);
18 value_init(cb);
19 barvinok_count(A, &cb, 0);
20 Polyhedron_Free(A);
21 Integer count(cb);
22 value_clear(cb);
23 p.take("LATTICE_POINTS") << count;
26 } }
28 using namespace polymake;
30 int main(int argc, const char *argv[])
32 if (argc != 2) {
33 return 1;
35 try {
36 Poly p(argv[1], ios::in | ios::out);
37 polytope::lattice_points(p);
38 } catch (const std::exception& e) {
39 cerr << e.what() << endl;
40 return 1;
42 return 0;