testlib.cc: work around incomplete namespace support in old compilers
[barvinok.git] / counter.h
blob8f54c890c3d9468d768a3b0ec9e1e514f0c483f8
1 #include "reducer.h"
3 struct counter : public np_base {
4 Vector *lambda;
5 Matrix *den;
6 ZZ sign;
7 Matrix *num;
8 int j;
9 mpq_t count;
10 Value tmp;
12 counter(unsigned dim, unsigned long max_index) : np_base(dim) {
13 mpq_init(count);
14 num = Matrix_Alloc(max_index, 1);
15 den = Matrix_Alloc(dim, 1);
16 lambda = Vector_Alloc(dim);
17 value_init(tmp);
20 virtual void init(Polyhedron *P) {
21 vec_ZZ l;
22 randomvector(P, l, dim);
23 zz2values(l, lambda->p);
26 virtual void reset() {
27 mpq_set_si(count, 0, 0);
30 ~counter() {
31 Matrix_Free(num);
32 Matrix_Free(den);
33 Vector_Free(lambda);
34 mpq_clear(count);
35 value_clear(tmp);
38 void add_falling_powers(dpoly& n, Value c);
39 virtual void handle(const mat_ZZ& rays, Value *vertex, const QQ& c,
40 unsigned long det, int *closed, barvinok_options *options);
41 virtual void get_count(Value *result) {
42 assert(value_one_p(&count[0]._mp_den));
43 value_assign(*result, &count[0]._mp_num);