1 #include <barvinok/options.h>
2 #include "param_util.h"
6 void Param_Vertex_Common_Denominator(Param_Vertices
*V
)
12 assert(V
->Vertex
->NbRows
> 0);
13 dim
= V
->Vertex
->NbColumns
-2;
17 value_assign(lcm
, V
->Vertex
->p
[0][dim
+1]);
18 for (i
= 1; i
< V
->Vertex
->NbRows
; ++i
)
19 value_lcm(V
->Vertex
->p
[i
][dim
+1], lcm
, &lcm
);
21 for (i
= 0; i
< V
->Vertex
->NbRows
; ++i
) {
22 if (value_eq(V
->Vertex
->p
[i
][dim
+1], lcm
))
24 value_division(V
->Vertex
->p
[i
][dim
+1], lcm
, V
->Vertex
->p
[i
][dim
+1]);
25 Vector_Scale(V
->Vertex
->p
[i
], V
->Vertex
->p
[i
],
26 V
->Vertex
->p
[i
][dim
+1], dim
+1);
27 value_assign(V
->Vertex
->p
[i
][dim
+1], lcm
);
33 /* Plug in the parametric vertex Vertex (nvar x (nparam + 2))
34 * in the constraint constraint (1 + nvar + nparam + 1).
35 * The result is stored in row (1 + nparam + 1),
36 * with the denominator in position 0.
38 void Param_Inner_Product(Value
*constraint
, Matrix
*Vertex
, Value
*row
)
40 unsigned nparam
= Vertex
->NbColumns
- 2;
41 unsigned nvar
= Vertex
->NbRows
;
45 value_set_si(row
[0], 1);
46 Vector_Set(row
+1, 0, nparam
+1);
51 for (j
= 0 ; j
< nvar
; ++j
) {
53 value_assign(tmp2
, constraint
[1+j
]);
54 if (value_ne(row
[0], Vertex
->p
[j
][nparam
+1])) {
55 value_assign(tmp
, row
[0]);
56 value_lcm(row
[0], Vertex
->p
[j
][nparam
+1], &row
[0]);
57 value_division(tmp
, row
[0], tmp
);
58 value_multiply(tmp2
, tmp2
, row
[0]);
59 value_division(tmp2
, tmp2
, Vertex
->p
[j
][nparam
+1]);
61 Vector_Combine(row
+1, Vertex
->p
[j
], row
+1, tmp
, tmp2
, nparam
+1);
64 Vector_Combine(row
+1, constraint
+1+nvar
, row
+1, tmp
, row
[0], nparam
+1);
70 static Param_Polyhedron
*PL_P2PP(Polyhedron
*Din
, Polyhedron
*Cin
,
71 struct barvinok_options
*options
)
73 unsigned MaxRays
= options
->MaxRays
;
74 if (MaxRays
& (POL_NO_DUAL
| POL_INTEGER
))
76 return Polyhedron2Param_Domain(Din
, Cin
, MaxRays
);
80 #ifndef POINTS2TRIANGS_PATH
81 Param_Polyhedron
*TC_P2PP(Polyhedron
*P
, Polyhedron
*C
,
82 struct barvinok_options
*options
)
88 Param_Polyhedron
*Polyhedron2Param_Polyhedron(Polyhedron
*P
, Polyhedron
*C
,
89 struct barvinok_options
*options
)
91 switch(options
->chambers
) {
92 case BV_CHAMBERS_POLYLIB
:
93 return PL_P2PP(P
, C
, options
);
95 case BV_CHAMBERS_TOPCOM
:
96 return TC_P2PP(P
, C
, options
);