3 #include <barvinok/polylib.h>
4 #include <barvinok/NTL_QQ.h>
8 // the number of times a given factor appears in the denominator
12 bfc_term_base(int len
) {
13 powers
= new int[len
];
16 virtual ~bfc_term_base() {
21 struct bfc_term
: public bfc_term_base
{
24 bfc_term(int len
) : bfc_term_base(len
) {}
27 typedef std::vector
< bfc_term_base
* > bfc_vec
;
31 struct bf_base
: public np_base
{
36 int lower
; // call base when only this many variables is left
38 bf_base(unsigned dim
) : np_base(dim
) {
51 virtual void handle(const mat_ZZ
& rays
, Value
*vertex
, const QQ
& c
,
52 unsigned long det
, int *closed
, barvinok_options
*options
);
53 int setup_factors(const mat_ZZ
& rays
, mat_ZZ
& factors
, bfc_term_base
* t
, int s
);
55 bfc_term_base
* find_bfc_term(bfc_vec
& v
, int *powers
, int len
);
56 void add_term(bfc_term_base
*t
, vec_ZZ
& num1
, vec_ZZ
& num
);
57 void add_term(bfc_term_base
*t
, vec_ZZ
& num
);
59 void reduce(mat_ZZ
& factors
, bfc_vec
& v
, barvinok_options
*options
);
60 virtual void base(mat_ZZ
& factors
, bfc_vec
& v
) = 0;
62 virtual bfc_term_base
* new_bf_term(int len
) = 0;
63 virtual void set_factor(bfc_term_base
*t
, int k
, int change
) = 0;
64 virtual void set_factor(bfc_term_base
*t
, int k
, mpq_t
&f
, int change
) = 0;
65 virtual void set_factor(bfc_term_base
*t
, int k
, const QQ
& c
, int change
) = 0;
66 virtual void update_term(bfc_term_base
*t
, int i
) = 0;
67 virtual void insert_term(bfc_term_base
*t
, int i
) = 0;
68 virtual bool constant_vertex(int dim
) = 0;
69 virtual void cum(bf_reducer
*bfr
, bfc_term_base
*t
, int k
,
70 dpoly_r
*r
, barvinok_options
*options
) = 0;
73 struct bfcounter_base
: public bf_base
{
76 bfcounter_base(unsigned dim
) : bf_base(dim
) {
79 bfc_term_base
* new_bf_term(int len
);
81 virtual void set_factor(bfc_term_base
*t
, int k
, int change
);
82 virtual void set_factor(bfc_term_base
*t
, int k
, mpq_t
&f
, int change
);
83 virtual void set_factor(bfc_term_base
*t
, int k
, const QQ
& c_factor
, int change
);
84 virtual void insert_term(bfc_term_base
*t
, int i
);
85 virtual void update_term(bfc_term_base
*t
, int i
);
87 virtual bool constant_vertex(int dim
) { return true; }
88 virtual void cum(bf_reducer
*bfr
, bfc_term_base
*t
, int k
, dpoly_r
*r
,
89 barvinok_options
*options
) {
110 int no_param
; // r from text
111 int only_param
; // k-r-s from text
112 int total_power
; // k from text
114 // created in compute_reduced_factors
116 // set in update_powers
121 bf_reducer(mat_ZZ
& factors
, bfc_vec
& v
, bf_base
*bf
)
122 : factors(factors
), v(v
), bf(bf
) {
123 nf
= factors
.NumRows();
124 d
= factors
.NumCols();
125 old2new
= new int[nf
];
128 extra_num
.SetLength(d
-1);
137 void compute_reduced_factors();
138 void compute_extra_num(int i
);
140 void reduce(barvinok_options
*options
);
142 void update_powers(const std::vector
<int>& powers
);