update pet for use of isl_map_has_tuple_id
[barvinok.git] / dpoly.h
blobb849ba753a48fadc0446b34c41f5bdcfe124c166
1 #ifndef DPOLY_H
2 #define DPOLY_H
4 #include <barvinok/set.h>
5 #include <vector>
6 #include <gmp.h>
7 #include <NTL/vec_ZZ.h>
8 #include <barvinok/polylib.h>
9 #include "conversion.h"
11 #ifdef NTL_STD_CXX
12 using namespace NTL;
13 #endif
15 class dpoly {
16 public:
17 Vector *coeff;
18 dpoly(const dpoly& o) {
19 coeff = Vector_Alloc(o.coeff->Size);
20 Vector_Copy(o.coeff->p, coeff->p, o.coeff->Size);
22 dpoly(int d) {
23 coeff = Vector_Alloc(d+1);
25 dpoly(int d, const Value degree, int offset = 0);
26 ~dpoly() {
27 Vector_Free(coeff);
29 void operator += (const dpoly& t);
30 void operator *= (const Value f);
31 void operator *= (const dpoly& f);
32 void div(const dpoly& d, mpq_t count, int sign);
33 void div(const dpoly& d, mpq_t *count, const mpq_t& factor);
34 Vector *div(const dpoly &d);
37 /* Each element in powers corresponds to a factor of the form (1 - z^b)
38 * and indicates the exponent of this factor in the denominator.
39 * The constants b are stored elsewhere (den_r in reducer::reducer).
41 struct dpoly_r_term {
42 std::vector<int> powers;
43 ZZ coeff;
46 struct dpoly_r_term_lex_smaller {
47 bool operator()(const dpoly_r_term* t1, const dpoly_r_term* t2) const {
48 return t1->powers < t2->powers;
52 typedef std::set<dpoly_r_term*, dpoly_r_term_lex_smaller> dpoly_r_term_list;
54 /* len: number of elements in c
55 * each element in c is the coefficient of a power of t
56 * in the MacLaurin expansion
58 struct dpoly_r {
59 dpoly_r_term_list *c;
60 int len;
61 int dim;
62 ZZ denom;
64 void add_term(int i, const std::vector<int>& powers, const ZZ& coeff);
65 dpoly_r(int len, int dim);
66 dpoly_r(dpoly& num, int dim);
67 dpoly_r(dpoly& num, dpoly& den, int pos, int dim);
68 dpoly_r(const dpoly_r* num, dpoly& den, int pos, int dim);
69 ~dpoly_r();
70 dpoly_r *div(const dpoly& d) const;
71 void dump(void);
74 #endif