counter.cc: extracted from barvinok.cc
[barvinok.git] / counter.h
blob1c5228d85fc2a10e511ddc770cfb6778815764a8
1 #include "reducer.h"
3 struct counter : public np_base {
4 vec_ZZ lambda;
5 mat_ZZ vertex;
6 vec_ZZ den;
7 ZZ sign;
8 vec_ZZ num;
9 ZZ offset;
10 int j;
11 mpq_t count;
12 Value tz;
14 counter(unsigned dim) : np_base(dim) {
15 den.SetLength(dim);
16 mpq_init(count);
17 value_init(tz);
20 virtual void init(Polyhedron *P) {
21 randomvector(P, lambda, dim);
24 virtual void reset() {
25 mpq_set_si(count, 0, 0);
28 ~counter() {
29 mpq_clear(count);
30 value_clear(tz);
33 virtual void handle(const mat_ZZ& rays, Value *vertex, const QQ& c,
34 unsigned long det, int *closed, barvinok_options *options);
35 virtual void get_count(Value *result) {
36 assert(value_one_p(&count[0]._mp_den));
37 value_assign(*result, &count[0]._mp_num);