4 #include <polylib/polylibgmp.h>
7 #include <barvinok/NTL_QQ.h>
10 struct bfc_term_base
{
11 // the number of times a given factor appears in the denominator
15 bfc_term_base(int len
) {
16 powers
= new int[len
];
19 virtual ~bfc_term_base() {
24 struct bfc_term
: public bfc_term_base
{
27 bfc_term(int len
) : bfc_term_base(len
) {}
30 typedef std::vector
< bfc_term_base
* > bfc_vec
;
34 struct bf_base
: public np_base
{
39 int lower
; // call base when only this many variables is left
41 bf_base(unsigned dim
) : np_base(dim
) {
54 virtual void handle_polar(Polyhedron
*C
, Value
*vertex
, QQ c
);
55 int setup_factors(Polyhedron
*P
, mat_ZZ
& factors
, bfc_term_base
* t
, int s
);
57 bfc_term_base
* find_bfc_term(bfc_vec
& v
, int *powers
, int len
);
58 void add_term(bfc_term_base
*t
, vec_ZZ
& num1
, vec_ZZ
& num
);
59 void add_term(bfc_term_base
*t
, vec_ZZ
& num
);
61 void reduce(mat_ZZ
& factors
, bfc_vec
& v
);
62 virtual void base(mat_ZZ
& factors
, bfc_vec
& v
) = 0;
64 virtual bfc_term_base
* new_bf_term(int len
) = 0;
65 virtual void set_factor(bfc_term_base
*t
, int k
, int change
) = 0;
66 virtual void set_factor(bfc_term_base
*t
, int k
, mpq_t
&f
, int change
) = 0;
67 virtual void set_factor(bfc_term_base
*t
, int k
, const QQ
& c
, int change
) = 0;
68 virtual void update_term(bfc_term_base
*t
, int i
) = 0;
69 virtual void insert_term(bfc_term_base
*t
, int i
) = 0;
70 virtual bool constant_vertex(int dim
) = 0;
71 virtual void cum(bf_reducer
*bfr
, bfc_term_base
*t
, int k
,
75 struct bfcounter_base
: public bf_base
{
78 bfcounter_base(unsigned dim
) : bf_base(dim
) {
81 bfc_term_base
* new_bf_term(int len
);
83 virtual void set_factor(bfc_term_base
*t
, int k
, int change
);
84 virtual void set_factor(bfc_term_base
*t
, int k
, mpq_t
&f
, int change
);
85 virtual void set_factor(bfc_term_base
*t
, int k
, const QQ
& c_factor
, int change
);
86 virtual void insert_term(bfc_term_base
*t
, int i
);
87 virtual void update_term(bfc_term_base
*t
, int i
);
89 virtual bool constant_vertex(int dim
) { return true; }
90 virtual void cum(bf_reducer
*bfr
, bfc_term_base
*t
, int k
, dpoly_r
*r
) {
111 int no_param
; // r from text
112 int only_param
; // k-r-s from text
113 int total_power
; // k from text
115 // created in compute_reduced_factors
117 // set in update_powers
122 bf_reducer(mat_ZZ
& factors
, bfc_vec
& v
, bf_base
*bf
)
123 : factors(factors
), v(v
), bf(bf
) {
124 nf
= factors
.NumRows();
125 d
= factors
.NumCols();
126 old2new
= new int[nf
];
129 extra_num
.SetLength(d
-1);
138 void compute_reduced_factors();
139 void compute_extra_num(int i
);
143 void update_powers(int *powers
, int len
);