5 #include <polylib/polylibgmp.h>
10 #ifdef HAVE_GROWING_CHERNIKOVA
16 #ifdef HAVE_SYS_TIMES_H
18 #include <sys/times.h>
20 static void time_diff(struct tms
*before
, struct tms
*after
)
22 long ticks
= sysconf(_SC_CLK_TCK
);
23 printf("User: %g; Sys: %g\n",
24 (0.0 + after
->tms_utime
- before
->tms_utime
) / ticks
,
25 (0.0 + after
->tms_stime
- before
->tms_stime
) / ticks
);
31 static void times(struct tms
* time
)
34 static void time_diff(struct tms
*before
, struct tms
*after
)
42 int i
, nbPol
, nbVec
, func
, j
;
43 Polyhedron
*A
, *B
, *C
, *D
, *E
, *F
, *G
;
49 ((sscanf(s
, "D %d", &nbPol
)<1) && (sscanf(s
, "V %d", &nbVec
)<1)) )
52 for (i
= 0; i
< nbPol
; ++i
) {
53 Matrix
*M
= Matrix_Read();
54 A
= Constraints2Polyhedron(M
, MAXRAYS
);
57 while ((*s
=='#') || (sscanf(s
, "F %d", &func
)<1))
66 /* workaround for apparent bug in older gmps */
67 *strchr(s
, '\n') = '\0';
68 while ((*s
=='#') || (value_read(ck
, s
) != 0)) {
70 /* workaround for apparent bug in older gmps */
71 *strchr(s
, '\n') = '\0';
73 barvinok_count(A
, &cb
, 100);
81 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
82 B
= Polyhedron_Polar(A
, MAXRAYS
);
83 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
84 C
= Polyhedron_Polar(B
, MAXRAYS
);
85 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
90 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
91 for (j
= 0; j
< A
->NbRays
; ++j
) {
92 B
= supporting_cone(A
, j
);
93 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
98 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
100 barvinok_decompose(A
,&B
,&C
);
102 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
104 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
110 struct tms tms_before
, tms_between
, tms_after
;
113 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
115 manual_count(A
, &cm
);
117 barvinok_count(A
, &cb
, 100);
120 value_print(stdout
, P_VALUE_FMT
, cm
);
122 time_diff(&tms_before
, &tms_between
);
123 printf("Barvinok: ");
124 value_print(stdout
, P_VALUE_FMT
, cb
);
126 time_diff(&tms_between
, &tms_after
);
132 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
133 B
= triangularize_cone(A
, 100);
134 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
135 check_triangulization(A
, B
);
139 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
140 B
= remove_equalities(A
);
141 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
147 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
148 B
= Polyhedron_Reduce(A
, &f
);
149 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
152 value_print(stdout
, P_VALUE_FMT
, f
);
159 Matrix
*M
= Matrix_Read();
161 C
= Constraints2Polyhedron(M
, MAXRAYS
);
163 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
164 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
165 en
= barvinok_enumerate(A
, C
, MAXRAYS
);
166 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
167 print_evalue(stdout
, &en
->EP
, param_name
);
168 Enumeration_Free(en
);
172 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
173 Polyhedron_Polarize(A
);
175 barvinok_decompose(A
,&B
,&C
);
176 for (D
= B
; D
; D
= D
->next
)
177 Polyhedron_Polarize(D
);
178 for (D
= C
; D
; D
= D
->next
)
179 Polyhedron_Polarize(D
);
181 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
183 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
190 for (i
= 0; i
< nbVec
; ++i
) {
191 Vector
*V
= Vector_Read();
192 Matrix
*M
= unimodular_complete(V
);
193 Matrix_Print(stdout
, P_VALUE_FMT
, M
);