genfun.cc: move coefficient computation to short_rat
[barvinok.git] / dpoly.h
blob4a8960e11df3223da85da76debb619989e904d5d
1 #ifndef DPOLY_H
2 #define DPOLY_H
4 #include <assert.h>
5 #include <set>
6 #include <vector>
7 #include <gmp.h>
8 #include <NTL/vec_ZZ.h>
9 #include <barvinok/polylib.h>
10 #include "conversion.h"
12 #ifdef NTL_STD_CXX
13 using namespace NTL;
14 #endif
16 class dpoly {
17 public:
18 vec_ZZ coeff;
19 dpoly(int d, ZZ& degree, int offset = 0);
20 void operator *= (dpoly& f);
21 void div(dpoly& d, mpq_t count, ZZ& sign);
22 void div(dpoly& d, mpq_t *count, const mpq_t& factor);
23 private:
24 mpq_t *div(dpoly &d) const;
25 void clear_div(mpq_t *c) const;
28 struct dpoly_r_term {
29 std::vector<int> powers;
30 ZZ coeff;
33 struct dpoly_r_term_lex_smaller {
34 bool operator()(const dpoly_r_term* t1, const dpoly_r_term* t2) const {
35 return t1->powers < t2->powers;
39 typedef std::set<dpoly_r_term*, dpoly_r_term_lex_smaller> dpoly_r_term_list;
41 /* len: number of elements in c
42 * each element in c is the coefficient of a power of t
43 * in the MacLaurin expansion
45 struct dpoly_r {
46 dpoly_r_term_list *c;
47 int len;
48 int dim;
49 ZZ denom;
51 void add_term(int i, const std::vector<int>& powers, const ZZ& coeff);
52 dpoly_r(int len, int dim);
53 dpoly_r(dpoly& num, int dim);
54 dpoly_r(dpoly& num, dpoly& den, int pos, int dim);
55 dpoly_r(dpoly_r* num, dpoly& den, int pos, int dim);
56 ~dpoly_r();
57 dpoly_r *div(dpoly& d);
58 void dump(void);
61 #endif