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
, nbMat
, 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
);
43 nbPol
= nbVec
= nbMat
= 0;
46 ((sscanf(s
, "D %d", &nbPol
) < 1) &&
47 (sscanf(s
, "V %d", &nbVec
) < 1) &&
48 (sscanf(s
, "M %d", &nbMat
) < 1)))
51 for (i
= 0; i
< nbPol
; ++i
) {
52 Matrix
*M
= Matrix_Read();
53 A
= Constraints2Polyhedron(M
, options
->MaxRays
);
56 while ((*s
=='#') || (sscanf(s
, "F %d", &func
)<1))
65 /* workaround for apparent bug in older gmps */
66 *strchr(s
, '\n') = '\0';
67 while ((*s
=='#') || (value_read(ck
, s
) != 0)) {
69 /* workaround for apparent bug in older gmps */
70 *strchr(s
, '\n') = '\0';
72 barvinok_count_with_options(A
, &cb
, options
);
80 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
81 B
= Polyhedron_Polar(A
, options
->MaxRays
);
82 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
83 C
= Polyhedron_Polar(B
, options
->MaxRays
);
84 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
89 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
90 for (j
= 0; j
< A
->NbRays
; ++j
) {
91 B
= supporting_cone(A
, j
);
92 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
97 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
99 barvinok_decompose(A
,&B
,&C
);
101 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
103 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
109 struct tms tms_before
, tms_between
, tms_after
;
112 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
114 manual_count(A
, &cm
);
116 barvinok_count(A
, &cb
, 100);
119 value_print(stdout
, P_VALUE_FMT
, cm
);
121 time_diff(&tms_before
, &tms_between
);
122 printf("Barvinok: ");
123 value_print(stdout
, P_VALUE_FMT
, cb
);
125 time_diff(&tms_between
, &tms_after
);
131 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
132 B
= triangulate_cone(A
, 100);
133 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
134 check_triangulization(A
, B
);
138 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
139 B
= remove_equalities(A
);
140 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
145 Matrix
*M
= Matrix_Read();
147 C
= Constraints2Polyhedron(M
, options
->MaxRays
);
149 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
150 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
151 EP
= barvinok_enumerate_with_options(A
, C
, options
);
152 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
153 print_evalue(stdout
, EP
, param_name
);
154 free_evalue_refs(EP
);
159 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
160 Polyhedron_Polarize(A
);
162 barvinok_decompose(A
,&B
,&C
);
163 for (D
= B
; D
; D
= D
->next
)
164 Polyhedron_Polarize(D
);
165 for (D
= C
; D
; D
= D
->next
)
166 Polyhedron_Polarize(D
);
168 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
170 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
177 for (i
= 0; i
< nbVec
; ++i
) {
178 Vector
*V
= Vector_Read();
179 Matrix
*M
= unimodular_complete(V
);
180 Matrix_Print(stdout
, P_VALUE_FMT
, M
);
184 for (i
= 0; i
< nbMat
; ++i
) {
186 Matrix
*M
= Matrix_Read();
187 Smith(M
, &U
, &V
, &S
);
188 Matrix_Print(stdout
, P_VALUE_FMT
, U
);
189 Matrix_Print(stdout
, P_VALUE_FMT
, V
);
190 Matrix_Print(stdout
, P_VALUE_FMT
, S
);
197 barvinok_options_free(options
);