doc: document polytope_sample
[barvinok.git] / barvinok / genfun.h
blobcf2ca98ab5cb0114c5498afa0739312175771db1
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>
13 #include <barvinok/options.h>
15 #ifdef NTL_STD_CXX
16 using namespace NTL;
17 #endif
19 struct short_rat {
20 struct __short_rat_n {
21 /* rows: terms in numerator */
22 /* coeff has two columns: the numerator and the denominator */
23 vec_QQ coeff;
24 mat_ZZ power;
25 } n;
26 struct __short_rat_d {
27 /* rows: factors in denominator */
28 mat_ZZ power;
29 } d;
30 void add(short_rat *rat);
31 bool reduced();
34 struct gen_fun {
35 std::vector< short_rat * > term;
36 Polyhedron *context;
38 void add(const QQ& c, const vec_ZZ& num, const mat_ZZ& den);
39 /* add c times gf */
40 void add(const QQ& c, const gen_fun *gf);
41 void substitute(Matrix *CP);
42 gen_fun *Hadamard_product(const gen_fun *gf, barvinok_options *options);
43 void add_union(gen_fun *gf, barvinok_options *options);
44 void shift(const vec_ZZ& offset);
45 void divide(const vec_ZZ& power);
46 void print(std::ostream& os, unsigned int nparam, char **param_name) const;
47 operator evalue *() const;
48 void coefficient(Value* params, Value* c) const;
49 gen_fun *summate(int nvar, barvinok_options *options) const;
50 bool summate(Value *sum) const;
52 gen_fun(const gen_fun *gf) {
53 QQ one(1, 1);
54 context = Polyhedron_Copy(gf->context);
55 add(one, gf);
57 gen_fun(Value c);
58 gen_fun(Polyhedron *C = NULL) : context(C) {}
59 ~gen_fun() {
60 if (context)
61 Polyhedron_Free(context);
62 for (int i = 0; i < term.size(); ++i)
63 delete term[i];
67 #endif