isl_qpolynomial_from_evalue: rename "dim" parameter to "space"
[barvinok.git] / barvinok / evalue.h
blob2ee6496e87dbe6f38411fb56c3589619b111966a
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_qpolynomial *isl_qpolynomial_from_evalue(
48 __isl_take isl_space *space, const evalue *e);
49 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_evalue(
50 __isl_take isl_space *dim, const evalue *e);
51 evalue *isl_qpolynomial_to_evalue(__isl_keep isl_qpolynomial *qp);
52 evalue *isl_pw_qpolynomial_to_evalue(__isl_keep isl_pw_qpolynomial *pwqp);
54 #define EVALUE_DOMAIN(ev) ((ev).x.D)
55 #define EVALUE_SET_DOMAIN(ev, D) \
56 do { \
57 value_set_si((ev).d, -1); \
58 EVALUE_DOMAIN(ev) = D; \
59 } while(0)
60 #define EVALUE_IS_DOMAIN(ev) (value_mone_p((ev).d))
62 #define EVALUE_IS_ZERO(ev) (value_pos_p((ev).d) && value_zero_p((ev).x.n))
63 #define EVALUE_IS_ONE(ev) (value_one_p((ev).d) && value_one_p((ev).x.n))
65 #define EVALUE_IS_NAN(ev) (value_cmp_si((ev).d, -2) == 0)
67 typedef struct _enode {
68 enode_type type; /* polynomial or periodic or evector */
69 int size; /* number of attached pointers */
70 int pos; /* parameter position */
71 evalue arr[1]; /* array of rational/pointer */
72 } enode;
74 typedef struct _enumeration {
76 Polyhedron *ValidityDomain; /* contraints on the parameters */
77 evalue EP; /* dimension = combined space */
78 struct _enumeration *next; /* Ehrhart Polynomial, corresponding
79 to parameter values inside the
80 domain ValidityDomain below */
81 } Enumeration;
84 void evalue_set_si(evalue *ev, int n, int d);
85 void evalue_set(evalue *ev, Value n, Value d);
86 void evalue_copy(evalue *dst, const evalue *src);
87 evalue *evalue_dup(const evalue *e);
88 evalue *evalue_zero();
89 evalue *evalue_nan();
90 evalue *evalue_var(int var);
91 void evalue_free(evalue *e);
92 enode *new_enode(enode_type type,int size,int pos);
93 enode *ecopy(enode *e);
94 int eequal(const evalue *e1, const evalue *e2);
95 void free_evalue_refs(evalue *e);
96 void print_evalue(FILE *DST, const evalue *e, const char **pname);
97 void print_enode(FILE *DST, enode *p, const char **pname);
98 void reduce_evalue (evalue *e);
99 void reduce_evalue_in_domain(evalue *e, Polyhedron *D);
100 void aep_evalue(evalue *e, int *ref);
101 void addeliminatedparams_evalue(evalue *e,Matrix *CT);
102 void addeliminatedparams_enum(evalue *e, Matrix *CT, Polyhedron *CEq,
103 unsigned MaxRays, unsigned nparam);
104 void eadd(const evalue *e1, evalue *res);
105 void emul(const evalue *e1, evalue *res);
106 void emask(evalue *mask, evalue *res);
107 int in_domain(Polyhedron *P, Value *list_args);
108 double compute_evalue(const evalue *e, Value *list_args);
109 Value *compute_poly(Enumeration *en,Value *list_args);
110 evalue *evalue_eval(const evalue *e, Value *values);
111 void evalue_mod2table(evalue *ev, int nparam);
112 void evalue_mod2relation(evalue *e);
113 void evalue_combine(evalue *e);
114 void evalue_range_reduction(evalue *e);
115 int evalue_range_reduction_in_domain(evalue *e, Polyhedron *D);
116 size_t evalue_size(evalue *e);
117 size_t domain_size(Polyhedron *D);
118 Enumeration* partition2enumeration(evalue *EP);
119 void evalue_frac2floor(evalue *e);
120 int evalue_floor2frac(evalue *e);
121 int evalue_frac2floor_in_domain(evalue *e, Polyhedron *D);
122 void evalue_frac2floor2(evalue *e, int shift);
123 int evalue_frac2floor_in_domain3(evalue *e, Polyhedron *D, int shift);
124 void evalue_frac2polynomial(evalue *e, int sign, unsigned MaxRays);
125 evalue *esum(evalue *E, int nvar);
126 evalue *evalue_sum(evalue *E, int nvar, unsigned MaxRays);
127 void eor(evalue *e1, evalue *res);
128 void evalue_denom(const evalue *e, Value *d);
129 void evalue_div(evalue *e, Value n);
130 void evalue_mul(evalue *e, Value n);
131 void evalue_mul_div(evalue *e, Value n, Value d);
132 void evalue_negate(evalue *e);
133 void evalue_add_constant(evalue *e, const Value cst);
134 void evalue_split_domains_into_orthants(evalue *e, unsigned MaxRays);
135 void evalue_extract_affine(const evalue *e, Value *coeff, Value *cst, Value *d);
136 evalue *affine2evalue(Value *coeff, Value denom, int nvar);
137 void evalue_substitute(evalue *e, evalue **subs);
138 void evalue_backsubstitute(evalue *e, Matrix *CP, unsigned MaxRays);
139 evalue *evalue_polynomial(Vector *c, const evalue* X);
140 void evalue_shift_variables(evalue *e, int first, int n);
141 void evalue_reorder_terms(evalue *e);
143 struct evalue_section {
144 Polyhedron *D;
145 evalue *E;
148 evalue *evalue_from_section_array(struct evalue_section *s, int n);
150 #if defined(__cplusplus)
152 #endif
154 #endif