5 #include <polylib/polylibgmp.h>
6 #include <barvinok/util.h>
7 #include <barvinok/barvinok.h>
10 #ifdef HAVE_GROWING_CHERNIKOVA
11 #define MAXRAYS POL_NO_DUAL
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
, MAXRAYS
);
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
= triangulate_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
);
146 Matrix
*M
= Matrix_Read();
148 C
= Constraints2Polyhedron(M
, MAXRAYS
);
150 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
151 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
152 EP
= barvinok_enumerate_ev(A
, C
, MAXRAYS
);
153 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
154 print_evalue(stdout
, EP
, param_name
);
155 free_evalue_refs(EP
);
160 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
161 Polyhedron_Polarize(A
);
163 barvinok_decompose(A
,&B
,&C
);
164 for (D
= B
; D
; D
= D
->next
)
165 Polyhedron_Polarize(D
);
166 for (D
= C
; D
; D
= D
->next
)
167 Polyhedron_Polarize(D
);
169 Polyhedron_Print(stdout
, P_VALUE_FMT
, B
);
171 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
178 for (i
= 0; i
< nbVec
; ++i
) {
179 Vector
*V
= Vector_Read();
180 Matrix
*M
= unimodular_complete(V
);
181 Matrix_Print(stdout
, P_VALUE_FMT
, M
);