update isl-polylib for change in pkg-config file
[barvinok.git] / barvinok / evalue.h
blob3b5d8c4354bbed648ae63a77389d86950ee82b2b
1 #ifndef EVALUE_H
2 #define EVALUE_H
4 #include <isl_polynomial.h>
5 #include <barvinok/polylib.h>
7 #if defined(__cplusplus)
8 extern "C" {
9 #endif
11 #define polynomial new_polynomial
12 #define periodic new_periodic
13 #define evector new_evector
14 #define enode_type new_enode_type
15 #define enode_node new_enode_node
16 #define _enumeration _new_enumeration
17 #define Enumeration _new_Enumeration
18 #define enode _new_enode
19 #define _enode _new__enode
20 #define evalue _new_evalue
21 #define _evalue _new__evalue
22 #define eadd _new_eadd
23 #define ecopy _new_ecopy
24 #define new_enode _new_new_enode
25 #define free_evalue_refs _new_free_evalue_refs
26 #define print_evalue _new_print_evalue
27 #define print_enode _new_print_enode
28 #define reduce_evalue _new_reduce
29 #define compute_evalue _new_compute_evalue
30 #define compute_poly _new_compute_poly
31 #define in_domain _new_in_domain
32 #define Enumeration_Free _new_Enumeration_Free
33 #define evalue_div _new_evalue_div
35 typedef enum { polynomial, periodic, evector, fractional, relation,
36 partition, flooring } enode_type;
38 typedef struct _evalue {
39 Value d; /* denominator */
40 union {
41 Value n; /* numerator (if denominator > 0) */
42 struct _enode *p; /* pointer (if denominator == 0) */
43 Polyhedron *D; /* domain (if denominator == -1) */
44 } x;
45 } evalue;
47 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_evalue(
48 __isl_take isl_dim *dim, const evalue *e);
49 evalue *isl_qpolynomial_to_evalue(__isl_keep isl_qpolynomial *qp);
50 evalue *isl_pw_qpolynomial_to_evalue(__isl_keep isl_pw_qpolynomial *pwqp);
52 #define EVALUE_DOMAIN(ev) ((ev).x.D)
53 #define EVALUE_SET_DOMAIN(ev, D) \
54 do { \
55 value_set_si((ev).d, -1); \
56 EVALUE_DOMAIN(ev) = D; \
57 } while(0)
58 #define EVALUE_IS_DOMAIN(ev) (value_mone_p((ev).d))
60 #define EVALUE_IS_ZERO(ev) (value_pos_p((ev).d) && value_zero_p((ev).x.n))
61 #define EVALUE_IS_ONE(ev) (value_one_p((ev).d) && value_one_p((ev).x.n))
63 #define EVALUE_IS_NAN(ev) (value_cmp_si((ev).d, -2) == 0)
65 typedef struct _enode {
66 enode_type type; /* polynomial or periodic or evector */
67 int size; /* number of attached pointers */
68 int pos; /* parameter position */
69 evalue arr[1]; /* array of rational/pointer */
70 } enode;
72 typedef struct _enumeration {
74 Polyhedron *ValidityDomain; /* contraints on the parameters */
75 evalue EP; /* dimension = combined space */
76 struct _enumeration *next; /* Ehrhart Polynomial, corresponding
77 to parameter values inside the
78 domain ValidityDomain below */
79 } Enumeration;
82 void evalue_set_si(evalue *ev, int n, int d);
83 void evalue_set(evalue *ev, Value n, Value d);
84 void evalue_copy(evalue *dst, const evalue *src);
85 evalue *evalue_dup(const evalue *e);
86 evalue *evalue_zero();
87 evalue *evalue_nan();
88 evalue *evalue_var(int var);
89 void evalue_free(evalue *e);
90 enode *new_enode(enode_type type,int size,int pos);
91 enode *ecopy(enode *e);
92 int eequal(const evalue *e1, const evalue *e2);
93 void free_evalue_refs(evalue *e);
94 void print_evalue(FILE *DST, const evalue *e, const char **pname);
95 void print_enode(FILE *DST, enode *p, const char **pname);
96 void reduce_evalue (evalue *e);
97 void reduce_evalue_in_domain(evalue *e, Polyhedron *D);
98 void aep_evalue(evalue *e, int *ref);
99 void addeliminatedparams_evalue(evalue *e,Matrix *CT);
100 void addeliminatedparams_enum(evalue *e, Matrix *CT, Polyhedron *CEq,
101 unsigned MaxRays, unsigned nparam);
102 void eadd(const evalue *e1, evalue *res);
103 void emul(const evalue *e1, evalue *res);
104 void emask(evalue *mask, evalue *res);
105 int in_domain(Polyhedron *P, Value *list_args);
106 double compute_evalue(const evalue *e, Value *list_args);
107 Value *compute_poly(Enumeration *en,Value *list_args);
108 evalue *evalue_eval(const evalue *e, Value *values);
109 void evalue_mod2table(evalue *ev, int nparam);
110 void evalue_mod2relation(evalue *e);
111 void evalue_combine(evalue *e);
112 void evalue_range_reduction(evalue *e);
113 int evalue_range_reduction_in_domain(evalue *e, Polyhedron *D);
114 size_t evalue_size(evalue *e);
115 size_t domain_size(Polyhedron *D);
116 Enumeration* partition2enumeration(evalue *EP);
117 void evalue_frac2floor(evalue *e);
118 int evalue_floor2frac(evalue *e);
119 int evalue_frac2floor_in_domain(evalue *e, Polyhedron *D);
120 void evalue_frac2floor2(evalue *e, int shift);
121 int evalue_frac2floor_in_domain3(evalue *e, Polyhedron *D, int shift);
122 void evalue_frac2polynomial(evalue *e, int sign, unsigned MaxRays);
123 evalue *esum(evalue *E, int nvar);
124 evalue *evalue_sum(evalue *E, int nvar, unsigned MaxRays);
125 void eor(evalue *e1, evalue *res);
126 void evalue_denom(const evalue *e, Value *d);
127 void evalue_div(evalue *e, Value n);
128 void evalue_mul(evalue *e, Value n);
129 void evalue_mul_div(evalue *e, Value n, Value d);
130 void evalue_negate(evalue *e);
131 void evalue_add_constant(evalue *e, const Value cst);
132 void evalue_split_domains_into_orthants(evalue *e, unsigned MaxRays);
133 void evalue_split_periods(evalue *e, int max_periods, unsigned int MaxRays);
134 void evalue_extract_affine(const evalue *e, Value *coeff, Value *cst, Value *d);
135 evalue *affine2evalue(Value *coeff, Value denom, int nvar);
136 void evalue_substitute(evalue *e, evalue **subs);
137 void evalue_backsubstitute(evalue *e, Matrix *CP, unsigned MaxRays);
138 evalue *evalue_polynomial(Vector *c, const evalue* X);
139 void evalue_shift_variables(evalue *e, int first, int n);
140 void evalue_reorder_terms(evalue *e);
142 struct evalue_section {
143 Polyhedron *D;
144 evalue *E;
147 evalue *evalue_from_section_array(struct evalue_section *s, int n);
149 #if defined(__cplusplus)
151 #endif
153 #endif