gen_fun: expose clear_terms, a method for clearing all terms of the gen_fun
[barvinok.git] / polymake / convert.cc
blob9c9414fd595e43799afa54cdf3a2ecb375c2a853
1 #include "convert.h"
3 namespace polymake { namespace polytope {
5 ::Matrix *polymake_constraints2polylib(Matrix<Rational> &F)
7 int r = F.rows();
8 int c = F.cols();
9 ::Matrix *M = Matrix_Alloc(r, c+1);
10 for (int i = 0; i < r; ++i) {
11 Integer LCM = denominator(F[i][0]);
12 for (int j = 1; j < c; ++j)
13 LCM = lcm(LCM, denominator(F[i][j]));
14 value_set_si(M->p[i][0], 1);
15 F[i][0] *= LCM;
16 value_assign(M->p[i][c], mpq_numref(F[i][0].get_rep()));
17 for (int j = 1; j < c; ++j) {
18 F[i][j] *= LCM;
19 value_assign(M->p[i][j], mpq_numref(F[i][j].get_rep()));
22 return M;
25 } }