gen_fun::Hadamard_product: don't assume equalities are independent
[barvinok.git] / genfun_constructor.h
blobe422eafbd842d7f54c5d5fe735d6aec145066c4b
1 #include <gmp.h>
2 #include <NTL/mat_ZZ.h>
3 extern "C" {
4 #include <polylib/polylibgmp.h>
6 #include <barvinok/util.h>
7 #include <barvinok/genfun.h>
8 #include "reducer.h"
9 #include "bfcounter.h"
11 #ifdef NTL_STD_CXX
12 using namespace NTL;
13 #endif
15 /* base for generating function counting */
16 struct gf_base {
17 np_base *base;
18 gen_fun *gf;
20 gf_base(np_base *npb, Polyhedron *context) : base(npb) {
21 gf = new gen_fun(context);
23 virtual ~gf_base() {
25 static gf_base *create(Polyhedron *context, unsigned dim, unsigned nparam);
27 void start_gf(Polyhedron *P, unsigned MaxRays) {
28 base->start(P, MaxRays);
32 struct partial_ireducer : public ireducer, public gf_base {
33 partial_ireducer(Polyhedron *context, unsigned dim, unsigned nparam) :
34 ireducer(dim), gf_base(this, context) {
35 lower = nparam;
37 ~partial_ireducer() {
39 virtual void base(QQ& c, const vec_ZZ& num, const mat_ZZ& den_f);
42 struct partial_reducer : public reducer, public gf_base {
43 vec_ZZ lambda;
44 vec_ZZ tmp;
46 partial_reducer(Polyhedron *context, unsigned dim, unsigned nparam) :
47 reducer(dim), gf_base(this, context) {
48 lower = nparam;
50 tmp.SetLength(dim - nparam);
52 virtual void init(Polyhedron *P) {
53 randomvector(P, lambda, dim - lower);
55 ~partial_reducer() {
57 virtual void base(QQ& c, const vec_ZZ& num, const mat_ZZ& den_f);
59 virtual void split(vec_ZZ& num, ZZ& num_s, vec_ZZ& num_p,
60 mat_ZZ& den_f, vec_ZZ& den_s, mat_ZZ& den_r);
63 struct partial_bfcounter : public bfcounter_base, public gf_base {
64 partial_bfcounter(Polyhedron *context, unsigned dim, unsigned nparam) :
65 bfcounter_base(dim), gf_base(this, context) {
66 lower = nparam;
68 ~partial_bfcounter() {
70 virtual void base(mat_ZZ& factors, bfc_vec& v);