4 #include <barvinok/util.h>
5 #include <barvinok/options.h>
6 #include <barvinok/basis_reduction.h>
9 #define ALLOCN(type,n) (type*)malloc((n) * sizeof(type))
12 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
15 struct option options
[] = {
16 { "direct", no_argument
, 0, 'd' },
17 { "version", no_argument
, 0, 'V' },
22 static void scan_poly(Polyhedron
*S
, int pos
, Value
*z
, Matrix
*T
)
28 v
= Vector_Alloc(T
->NbRows
);
29 Matrix_Vector_Product(T
, z
+1, v
->p
);
30 value_print(stdout
, VALUE_FMT
, v
->p
[0]);
31 for (k
=1; k
< pos
; ++k
) {
33 value_print(stdout
,VALUE_FMT
, v
->p
[k
]);
43 ok
= !(lower_upper_bounds(1+pos
, S
, z
, &LB
, &UB
));
45 for (value_assign(tmp
,LB
); value_le(tmp
,UB
); value_increment(tmp
,tmp
)) {
46 value_assign(z
[pos
+1], tmp
);
47 scan_poly(S
->next
, pos
+1, z
, T
);
49 value_set_si(z
[pos
+1], 0);
56 int main(int argc
, char **argv
)
58 Polyhedron
*A
, *P
, *U
, *S
;
61 Matrix
*basis
, *T
, *inv
;
64 struct barvinok_options
*bv_options
= barvinok_options_new_with_defaults();
66 while ((c
= getopt_long(argc
, argv
, "dV", options
, &ind
)) != -1) {
72 printf(barvinok_version());
78 A
= Polyhedron_Read(bv_options
->MaxRays
);
81 inv
= Identity(A
->Dimension
+1);
84 basis
= Polyhedron_Reduced_Basis(A
, bv_options
);
86 T
= Matrix_Alloc(A
->Dimension
+1, A
->Dimension
+1);
87 inv
= Matrix_Alloc(A
->Dimension
+1, A
->Dimension
+1);
88 for (i
= 0; i
< A
->Dimension
; ++i
)
89 for (j
= 0; j
< A
->Dimension
; ++j
)
90 value_assign(T
->p
[i
][j
], basis
->p
[i
][j
]);
91 value_set_si(T
->p
[A
->Dimension
][A
->Dimension
], 1);
94 ok
= Matrix_Inverse(T
, inv
);
98 P
= Polyhedron_Preimage(A
, inv
, bv_options
->MaxRays
);
102 U
= Universe_Polyhedron(0);
103 S
= Polyhedron_Scan(P
, U
, bv_options
->MaxRays
);
105 p
= ALLOCN(Value
, P
->Dimension
+2);
106 for(i
=0;i
<=P
->Dimension
;i
++) {
108 value_set_si(p
[i
],0);
111 value_set_si(p
[i
],1);
113 scan_poly(S
, 0, p
, inv
);
116 for(i
=0;i
<=(P
->Dimension
+1);i
++)
122 barvinok_options_free(bv_options
);