Merge branch 'topcom'
[barvinok.git] / counter.h
blobc741012bc145710d8ec88cdc0e91c9ed6b8440d4
1 #include "reducer.h"
3 struct counter : public np_base {
4 Vector *lambda;
5 Matrix *den;
6 Matrix *num;
7 mpq_t count;
8 Value tmp;
10 counter(unsigned dim, unsigned long max_index) : np_base(dim) {
11 mpq_init(count);
12 num = Matrix_Alloc(max_index, 1);
13 den = Matrix_Alloc(dim, 1);
14 lambda = Vector_Alloc(dim);
15 value_init(tmp);
18 virtual void init(Polyhedron *P) {
19 vec_ZZ l;
20 randomvector(P, l, dim);
21 zz2values(l, lambda->p);
24 virtual void reset() {
25 mpq_set_si(count, 0, 0);
28 ~counter() {
29 Matrix_Free(num);
30 Matrix_Free(den);
31 Vector_Free(lambda);
32 mpq_clear(count);
33 value_clear(tmp);
36 void add_falling_powers(dpoly& n, Value c);
37 virtual void handle(const mat_ZZ& rays, Value *vertex, const QQ& c,
38 unsigned long det, barvinok_options *options);
39 virtual void get_count(Value *result) {
40 assert(value_one_p(&count[0]._mp_den));
41 value_assign(*result, &count[0]._mp_num);