evalue.c: reorder_terms: fix typo
[barvinok.git] / dpoly.h
blobfeb2bea79bd336f68e599f55afdf59b0dd80248f
1 #ifndef DPOLY_H
2 #define DPOLY_H
4 #include <assert.h>
5 #include <barvinok/set.h>
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 Vector *coeff;
19 dpoly(const dpoly& o) {
20 coeff = Vector_Alloc(o.coeff->Size);
21 Vector_Copy(o.coeff->p, coeff->p, o.coeff->Size);
23 dpoly(int d) {
24 coeff = Vector_Alloc(d+1);
26 dpoly(int d, const Value degree, int offset = 0);
27 ~dpoly() {
28 Vector_Free(coeff);
30 void operator += (const dpoly& t);
31 void operator *= (const Value f);
32 void operator *= (const dpoly& f);
33 void div(const dpoly& d, mpq_t count, ZZ& sign);
34 void div(const dpoly& d, mpq_t *count, const mpq_t& factor);
35 Vector *div(const dpoly &d);
38 /* Each element in powers corresponds to a factor of the form (1 - z^b)
39 * and indicates the exponent of this factor in the denominator.
40 * The constants b are stored elsewhere (den_r in reducer::reducer).
42 struct dpoly_r_term {
43 std::vector<int> powers;
44 ZZ coeff;
47 struct dpoly_r_term_lex_smaller {
48 bool operator()(const dpoly_r_term* t1, const dpoly_r_term* t2) const {
49 return t1->powers < t2->powers;
53 typedef std::set<dpoly_r_term*, dpoly_r_term_lex_smaller> dpoly_r_term_list;
55 /* len: number of elements in c
56 * each element in c is the coefficient of a power of t
57 * in the MacLaurin expansion
59 struct dpoly_r {
60 dpoly_r_term_list *c;
61 int len;
62 int dim;
63 ZZ denom;
65 void add_term(int i, const std::vector<int>& powers, const ZZ& coeff);
66 dpoly_r(int len, int dim);
67 dpoly_r(dpoly& num, int dim);
68 dpoly_r(dpoly& num, dpoly& den, int pos, int dim);
69 dpoly_r(const dpoly_r* num, dpoly& den, int pos, int dim);
70 ~dpoly_r();
71 dpoly_r *div(const dpoly& d) const;
72 void dump(void);
75 #endif