1 #include <barvinok/options.h>
2 #include "param_util.h"
4 void Param_Vertex_Common_Denominator(Param_Vertices
*V
)
10 assert(V
->Vertex
->NbRows
> 0);
11 dim
= V
->Vertex
->NbColumns
-2;
15 value_assign(lcm
, V
->Vertex
->p
[0][dim
+1]);
16 for (i
= 1; i
< V
->Vertex
->NbRows
; ++i
)
17 value_lcm(V
->Vertex
->p
[i
][dim
+1], lcm
, &lcm
);
19 for (i
= 0; i
< V
->Vertex
->NbRows
; ++i
) {
20 if (value_eq(V
->Vertex
->p
[i
][dim
+1], lcm
))
22 value_division(V
->Vertex
->p
[i
][dim
+1], lcm
, V
->Vertex
->p
[i
][dim
+1]);
23 Vector_Scale(V
->Vertex
->p
[i
], V
->Vertex
->p
[i
],
24 V
->Vertex
->p
[i
][dim
+1], dim
+1);
25 value_assign(V
->Vertex
->p
[i
][dim
+1], lcm
);
31 /* Plug in the parametric vertex Vertex (nvar x (nparam + 2))
32 * in the constraint constraint (1 + nvar + nparam + 1).
33 * The result is stored in row (1 + nparam + 1),
34 * with the denominator in position 0.
36 void Param_Inner_Product(Value
*constraint
, Matrix
*Vertex
, Value
*row
)
38 unsigned nparam
= Vertex
->NbColumns
- 2;
39 unsigned nvar
= Vertex
->NbRows
;
43 value_set_si(row
[0], 1);
44 Vector_Set(row
+1, 0, nparam
+1);
49 for (j
= 0 ; j
< nvar
; ++j
) {
51 value_assign(tmp2
, constraint
[1+j
]);
52 if (value_ne(row
[0], Vertex
->p
[j
][nparam
+1])) {
53 value_assign(tmp
, row
[0]);
54 value_lcm(row
[0], Vertex
->p
[j
][nparam
+1], &row
[0]);
55 value_division(tmp
, row
[0], tmp
);
56 value_multiply(tmp2
, tmp2
, row
[0]);
57 value_division(tmp2
, tmp2
, Vertex
->p
[j
][nparam
+1]);
59 Vector_Combine(row
+1, Vertex
->p
[j
], row
+1, tmp
, tmp2
, nparam
+1);
62 Vector_Combine(row
+1, constraint
+1+nvar
, row
+1, tmp
, row
[0], nparam
+1);
68 Param_Polyhedron
*Polyhedron2Param_Polyhedron(Polyhedron
*Din
, Polyhedron
*Cin
,
69 struct barvinok_options
*options
)
71 unsigned MaxRays
= options
->MaxRays
;
72 if (MaxRays
& POL_NO_DUAL
)
74 return Polyhedron2Param_Domain(Din
, Cin
, MaxRays
);