4 #include <polylib/polylibgmp.h>
5 #include <barvinok/util.h>
6 #include <barvinok/options.h>
7 #include <barvinok/basis_reduction.h>
10 #define ALLOCN(type,n) (type*)malloc((n) * sizeof(type))
13 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
16 struct option options
[] = {
17 { "direct", no_argument
, 0, 'd' },
18 { "version", no_argument
, 0, 'V' },
23 static void scan_poly(Polyhedron
*S
, int pos
, Value
*z
, Matrix
*T
)
29 v
= Vector_Alloc(T
->NbRows
);
30 Matrix_Vector_Product(T
, z
+1, v
->p
);
31 value_print(stdout
, VALUE_FMT
, v
->p
[0]);
32 for (k
=1; k
< pos
; ++k
) {
34 value_print(stdout
,VALUE_FMT
, v
->p
[k
]);
44 ok
= !(lower_upper_bounds(1+pos
, S
, z
, &LB
, &UB
));
46 for (value_assign(tmp
,LB
); value_le(tmp
,UB
); value_increment(tmp
,tmp
)) {
47 value_assign(z
[pos
+1], tmp
);
48 scan_poly(S
->next
, pos
+1, z
, T
);
50 value_set_si(z
[pos
+1], 0);
57 int main(int argc
, char **argv
)
59 Polyhedron
*A
, *P
, *U
, *S
;
62 Matrix
*basis
, *T
, *inv
;
65 struct barvinok_options
*bv_options
= barvinok_options_new_with_defaults();
67 while ((c
= getopt_long(argc
, argv
, "dV", options
, &ind
)) != -1) {
73 printf(barvinok_version());
79 A
= Polyhedron_Read(bv_options
->MaxRays
);
82 inv
= Identity(A
->Dimension
+1);
85 basis
= Polyhedron_Reduced_Basis(A
);
87 T
= Matrix_Alloc(A
->Dimension
+1, A
->Dimension
+1);
88 inv
= Matrix_Alloc(A
->Dimension
+1, A
->Dimension
+1);
89 for (i
= 0; i
< A
->Dimension
; ++i
)
90 for (j
= 0; j
< A
->Dimension
; ++j
)
91 value_assign(T
->p
[i
][j
], basis
->p
[i
][j
]);
92 value_set_si(T
->p
[A
->Dimension
][A
->Dimension
], 1);
95 ok
= Matrix_Inverse(T
, inv
);
99 P
= Polyhedron_Preimage(A
, inv
, bv_options
->MaxRays
);
103 U
= Universe_Polyhedron(0);
104 S
= Polyhedron_Scan(P
, U
, bv_options
->MaxRays
);
106 p
= ALLOCN(Value
, P
->Dimension
+2);
107 for(i
=0;i
<=P
->Dimension
;i
++) {
109 value_set_si(p
[i
],0);
112 value_set_si(p
[i
],1);
114 scan_poly(S
, 0, p
, inv
);
117 for(i
=0;i
<=(P
->Dimension
+1);i
++)