scale.c: move Param_Vertex_Common_Denominator to param_util.c
[barvinok.git] / param_util.c
blobc45f38e967d332b392caad4a27ffa24f3da943c2
1 #include "param_util.h"
3 void Param_Vertex_Common_Denominator(Param_Vertices *V)
5 unsigned dim;
6 Value lcm;
7 int i;
9 assert(V->Vertex->NbRows > 0);
10 dim = V->Vertex->NbColumns-2;
12 value_init(lcm);
14 value_assign(lcm, V->Vertex->p[0][dim+1]);
15 for (i = 1; i < V->Vertex->NbRows; ++i)
16 value_lcm(V->Vertex->p[i][dim+1], lcm, &lcm);
18 for (i = 0; i < V->Vertex->NbRows; ++i) {
19 if (value_eq(V->Vertex->p[i][dim+1], lcm))
20 continue;
21 value_division(V->Vertex->p[i][dim+1], lcm, V->Vertex->p[i][dim+1]);
22 Vector_Scale(V->Vertex->p[i], V->Vertex->p[i],
23 V->Vertex->p[i][dim+1], dim+1);
24 value_assign(V->Vertex->p[i][dim+1], lcm);
27 value_clear(lcm);