make counter::add_falling_powers static
[barvinok.git] / counter.h
blobfe04530a261ff23cf22f8b88f89154ad0de38ee7
1 #include "reducer.h"
3 struct counter_base: public np_base {
4 Vector *lambda;
5 Matrix *den;
6 Matrix *num;
7 mpq_t count;
8 Value tmp;
10 counter_base(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 ~counter_base() {
25 Matrix_Free(num);
26 Matrix_Free(den);
27 Vector_Free(lambda);
28 mpq_clear(count);
29 value_clear(tmp);
32 virtual void add_lattice_points(int sign) = 0;
34 virtual void handle(const mat_ZZ& rays, Value *vertex, const QQ& c,
35 unsigned long det, barvinok_options *options);
36 virtual void get_count(Value *result) {
37 assert(value_one_p(&count[0]._mp_den));
38 value_assign(*result, &count[0]._mp_num);
42 struct counter : public counter_base {
43 counter(unsigned dim, unsigned long max_index) :
44 counter_base(dim, max_index) {}
46 virtual void reset() {
47 mpq_set_si(count, 0, 0);
50 virtual void add_lattice_points(int sign);
53 struct tcounter : public counter_base {
54 mpq_t tcount;
55 dpoly todd;
56 Vector *todd_denom;
57 Value denom;
59 tcounter(unsigned dim, unsigned long max_index) :
60 counter_base(dim, max_index), todd(dim) {
61 mpq_init(tcount);
62 setup_todd(dim);
63 value_init(denom);
66 void setup_todd(unsigned dim);
68 void adapt_todd(dpoly& t, const Value c);
69 void add_powers(dpoly& n, const Value c);
71 ~tcounter() {
72 mpq_clear(tcount);
73 Vector_Free(todd_denom);
74 value_clear(denom);
77 virtual void add_lattice_points(int sign);