4 #include "ev_operations.h"
7 static long long value_bitsize(Value v
);
8 static long long domain_bitsize(Polyhedron
*D
);
9 static long long enode_bitsize(enode
*p
);
10 static long long evalue_bitsize(evalue
*e
);
11 static long long Enumeration_bitsize(Enumeration
*en
);
13 long long value_bitsize(Value v
)
15 int last
= (v
[0]._mp_size
> 0 ? v
[0]._mp_size
: -v
[0]._mp_size
) - 1;
19 return last
* sizeof(v
[0]._mp_d
[0]) * 8 + ffs(v
[0]._mp_d
[last
]) + 1;
22 long long domain_bitsize(Polyhedron
*D
)
25 long long s
= ffs(D
->Dimension
) + ffs(D
->NbConstraints
);
27 for (i
= 0; i
< D
->NbConstraints
; ++i
)
28 for (j
= 0; j
< D
->Dimension
+2; ++j
)
29 s
+= value_bitsize(D
->Constraint
[i
][j
]);
31 return D
->next
? s
+domain_bitsize(D
->next
) : s
;
34 long long enode_bitsize(enode
*p
)
36 //long long s = (sizeof(*p) - sizeof(p->arr[0])) * 8;
37 long long s
= ffs(p
->size
);
40 if (p
->type
== partition
)
41 for (i
= 0; i
< p
->size
/2; ++i
) {
42 s
+= domain_bitsize(EVALUE_DOMAIN(p
->arr
[2*i
]));
43 s
+= evalue_bitsize(&p
->arr
[2*i
+1]);
46 for (i
= 0; i
< p
->size
; ++i
) {
47 s
+= evalue_bitsize(&p
->arr
[i
]);
52 long long evalue_bitsize(evalue
*e
)
54 //long long s = sizeof(*e) * 8;
56 s
+= value_bitsize(e
->d
);
57 if (value_notzero_p(e
->d
))
58 s
+= value_bitsize(e
->x
.n
);
60 s
+= enode_bitsize(e
->x
.p
);
64 long long Enumeration_bitsize(Enumeration
*en
)
68 for (; en
; en
= en
->next
) {
69 s
+= domain_bitsize(en
->ValidityDomain
);
70 s
+= evalue_bitsize(&en
->EP
);
75 evalue
* barvinok_enumerate_ev(Polyhedron
*P
, Polyhedron
* C
, unsigned MaxRays
)
77 static evalue
*(*orig
)(Polyhedron
*, Polyhedron
*c
, unsigned) = NULL
;
82 void *handle
= dlopen("libbarvinok.so", RTLD_LAZY
);
84 orig
= dlsym(handle
, "barvinok_enumerate_ev");
89 res
= orig(P
, C
, MaxRays
);
91 fprintf(stderr
, "SIZE: %d %lld %lld\n", P
->Dimension
- P
->NbEq
,
92 domain_bitsize(P
) + domain_bitsize(C
), evalue_bitsize(res
));
99 Enumeration
*Polyhedron_Enumerate(Polyhedron
*P
,Polyhedron
*C
,unsigned MAXRAYS
,char **param_name
)
101 static Enumeration
*(*orig
)(Polyhedron
*, Polyhedron
*c
, unsigned, char **) = NULL
;
106 void *handle
= dlopen("libpolylibgmp.so", RTLD_LAZY
);
108 orig
= dlsym(handle
, "Polyhedron_Enumerate");
113 res
= orig(P
, C
, MAXRAYS
, param_name
);
115 fprintf(stderr
, "SIZE: %d %lld %lld\n", P
->Dimension
- P
->NbEq
,
116 domain_bitsize(P
) + domain_bitsize(C
), Enumeration_bitsize(res
));