gen_fun: add constructor for generating function with no variables
[barvinok.git] / barvinok / genfun.h
blob39aae1f397bb8a7568508c9e9f9404c04108d954
1 #ifndef GENFUN_H
2 #define GENFUN_H
4 #include <vector>
5 #include <iostream>
6 #include <gmp.h>
7 #include <NTL/mat_ZZ.h>
8 extern "C" {
9 #include <polylib/polylibgmp.h>
10 #include <barvinok/evalue.h>
12 #include <barvinok/NTL_QQ.h>
14 #ifdef NTL_STD_CXX
15 using namespace NTL;
16 #endif
18 struct short_rat {
19 struct __short_rat_n {
20 /* rows: terms in numerator */
21 /* coeff has two columns: the numerator and the denominator */
22 vec_QQ coeff;
23 mat_ZZ power;
24 } n;
25 struct __short_rat_d {
26 /* rows: factors in denominator */
27 mat_ZZ power;
28 } d;
29 void add(short_rat *rat);
30 bool reduced();
33 struct gen_fun {
34 std::vector< short_rat * > term;
35 Polyhedron *context;
37 void add(const QQ& c, const vec_ZZ& num, const mat_ZZ& den);
38 /* add cn/cd times gf */
39 void add(const QQ& c, const gen_fun *gf);
40 void substitute(Matrix *CP);
41 gen_fun *Hadamard_product(const gen_fun *gf, unsigned MaxRays);
42 void add_union(gen_fun *gf, unsigned MaxRays);
43 void shift(const vec_ZZ& offset);
44 void divide(const vec_ZZ& power);
45 void print(std::ostream& os, unsigned int nparam, char **param_name) const;
46 operator evalue *() const;
47 void coefficient(Value* params, Value* c) const;
48 gen_fun *summate(int nvar) const;
49 bool summate(Value *sum) const;
51 gen_fun(const gen_fun *gf) {
52 QQ one(1, 1);
53 context = Polyhedron_Copy(gf->context);
54 add(one, gf);
56 gen_fun(Value c);
57 gen_fun(Polyhedron *C = NULL) : context(C) {}
58 ~gen_fun() {
59 if (context)
60 Polyhedron_Free(context);
61 for (int i = 0; i < term.size(); ++i)
62 delete term[i];
66 #endif