5 #include <barvinok/util.h>
6 #include <barvinok/barvinok.h>
10 #ifdef HAVE_SYS_TIMES_H
12 #include <sys/times.h>
14 static void time_diff(struct tms
*before
, struct tms
*after
)
16 long ticks
= sysconf(_SC_CLK_TCK
);
17 printf("User: %g; Sys: %g\n",
18 (0.0 + after
->tms_utime
- before
->tms_utime
) / ticks
,
19 (0.0 + after
->tms_stime
- before
->tms_stime
) / ticks
);
25 static void times(struct tms
* time
)
28 static void time_diff(struct tms
*before
, struct tms
*after
)
34 int main(int argc
, char **argv
)
36 int i
, nbPol
, nbVec
, func
, j
;
37 Polyhedron
*A
, *B
, *C
, *D
, *E
, *F
, *G
;
39 struct barvinok_options
*options
= barvinok_options_new_with_defaults();
41 argp_parse(&barvinok_argp
, argc
, argv
, 0, 0, options
);
46 ((sscanf(s
, "D %d", &nbPol
)<1) && (sscanf(s
, "V %d", &nbVec
)<1)) )
49 for (i
= 0; i
< nbPol
; ++i
) {
50 Matrix
*M
= Matrix_Read();
51 A
= Constraints2Polyhedron(M
, options
->MaxRays
);
54 while ((*s
=='#') || (sscanf(s
, "F %d", &func
)<1))
63 /* workaround for apparent bug in older gmps */
64 *strchr(s
, '\n') = '\0';
65 while ((*s
=='#') || (value_read(ck
, s
) != 0)) {
67 /* workaround for apparent bug in older gmps */
68 *strchr(s
, '\n') = '\0';
70 barvinok_count_with_options(A
, &cb
, options
);
78 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
79 B
= Polyhedron_Polar(A
, options
->MaxRays
);
80 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
81 C
= Polyhedron_Polar(B
, options
->MaxRays
);
82 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
87 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
88 for (j
= 0; j
< A
->NbRays
; ++j
) {
89 B
= supporting_cone(A
, j
);
90 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
95 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
97 barvinok_decompose(A
,&B
,&C
);
99 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
101 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
107 struct tms tms_before
, tms_between
, tms_after
;
110 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
112 manual_count(A
, &cm
);
114 barvinok_count(A
, &cb
, 100);
117 value_print(stdout
, P_VALUE_FMT
, cm
);
119 time_diff(&tms_before
, &tms_between
);
120 printf("Barvinok: ");
121 value_print(stdout
, P_VALUE_FMT
, cb
);
123 time_diff(&tms_between
, &tms_after
);
129 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
130 B
= triangulate_cone(A
, 100);
131 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
132 check_triangulization(A
, B
);
136 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
137 B
= remove_equalities(A
);
138 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
143 Matrix
*M
= Matrix_Read();
145 C
= Constraints2Polyhedron(M
, options
->MaxRays
);
147 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
148 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
149 EP
= barvinok_enumerate_with_options(A
, C
, options
);
150 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
151 print_evalue(stdout
, EP
, param_name
);
152 free_evalue_refs(EP
);
157 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
158 Polyhedron_Polarize(A
);
160 barvinok_decompose(A
,&B
,&C
);
161 for (D
= B
; D
; D
= D
->next
)
162 Polyhedron_Polarize(D
);
163 for (D
= C
; D
; D
= D
->next
)
164 Polyhedron_Polarize(D
);
166 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
168 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
175 for (i
= 0; i
< nbVec
; ++i
) {
176 Vector
*V
= Vector_Read();
177 Matrix
*M
= unimodular_complete(V
);
178 Matrix_Print(stdout
, P_VALUE_FMT
, M
);