dpoly: add some documentation
[barvinok.git] / genfun_constructor.h
blob17e1ca20832d749499d3f26915faa2790b5273ad
1 #include <gmp.h>
2 #include <NTL/mat_ZZ.h>
3 #include <barvinok/util.h>
4 #include <barvinok/genfun.h>
5 #include <barvinok/options.h>
6 #include "reducer.h"
7 #include "bfcounter.h"
9 #ifdef NTL_STD_CXX
10 using namespace NTL;
11 #endif
13 /* base for generating function counting */
14 struct gf_base {
15 np_base *base;
16 gen_fun *gf;
18 gf_base(np_base *npb, Polyhedron *context) : base(npb) {
19 gf = new gen_fun(context);
21 virtual ~gf_base() {
23 static gf_base *create(Polyhedron *context, unsigned dim, unsigned nparam,
24 barvinok_options *options);
26 void start_gf(Polyhedron *P, barvinok_options *options) {
27 base->start(P, options);
31 struct partial_ireducer : public ireducer, public gf_base {
32 partial_ireducer(Polyhedron *context, unsigned dim, unsigned nparam) :
33 ireducer(dim), gf_base(this, context) {
34 lower = nparam;
36 ~partial_ireducer() {
38 virtual void base(QQ& c, const vec_ZZ& num, const mat_ZZ& den_f);
39 virtual gen_fun *get_gf() {
40 return gf;
44 struct partial_reducer : public reducer, public gf_base {
45 vec_ZZ lambda;
46 vec_ZZ tmp;
48 partial_reducer(Polyhedron *context, unsigned dim, unsigned nparam) :
49 reducer(dim), gf_base(this, context) {
50 lower = nparam;
52 tmp.SetLength(dim - nparam);
54 virtual void init(Polyhedron *P) {
55 randomvector(P, lambda, dim - lower);
57 virtual void reset() {
58 gf->clear_terms();
60 ~partial_reducer() {
62 virtual void base(QQ& c, const vec_ZZ& num, const mat_ZZ& den_f);
64 virtual void split(vec_ZZ& num, ZZ& num_s, vec_ZZ& num_p,
65 const mat_ZZ& den_f, vec_ZZ& den_s, mat_ZZ& den_r);
66 virtual gen_fun *get_gf() {
67 return gf;
71 struct partial_bfcounter : public bfcounter_base, public gf_base {
72 partial_bfcounter(Polyhedron *context, unsigned dim, unsigned nparam) :
73 bfcounter_base(dim), gf_base(this, context) {
74 lower = nparam;
76 ~partial_bfcounter() {
78 virtual void base(mat_ZZ& factors, bfc_vec& v);