4 #include <barvinok/polylib.h>
6 #if defined(__cplusplus)
10 #define polynomial new_polynomial
11 #define periodic new_periodic
12 #define evector new_evector
13 #define enode_type new_enode_type
14 #define enode_node new_enode_node
15 #define _enumeration _new_enumeration
16 #define Enumeration _new_Enumeration
17 #define enode _new_enode
18 #define _enode _new__enode
19 #define evalue _new_evalue
20 #define _evalue _new__evalue
21 #define eadd _new_eadd
22 #define ecopy _new_ecopy
23 #define new_enode _new_new_enode
24 #define free_evalue_refs _new_free_evalue_refs
25 #define print_evalue _new_print_evalue
26 #define print_enode _new_print_enode
27 #define reduce_evalue _new_reduce
28 #define compute_evalue _new_compute_evalue
29 #define compute_poly _new_compute_poly
30 #define in_domain _new_in_domain
31 #define Enumeration_Free _new_Enumeration_Free
33 typedef enum { polynomial
, periodic
, evector
, fractional
, relation
,
34 partition
, flooring
} enode_type
;
36 typedef struct _evalue
{
37 Value d
; /* denominator */
39 Value n
; /* numerator (if denominator > 0) */
40 struct _enode
*p
; /* pointer (if denominator == 0) */
41 Polyhedron
*D
; /* domain (if denominator == -1) */
45 #define EVALUE_DOMAIN(ev) ((ev).x.D)
46 #define EVALUE_SET_DOMAIN(ev, D) \
48 value_set_si((ev).d, -1); \
49 EVALUE_DOMAIN(ev) = D; \
51 #define EVALUE_IS_DOMAIN(ev) (value_mone_p((ev).d))
53 #define EVALUE_IS_ZERO(ev) (value_pos_p((ev).d) && value_zero_p((ev).x.n))
54 #define EVALUE_IS_ONE(ev) (value_one_p((ev).d) && value_one_p((ev).x.n))
56 typedef struct _enode
{
57 enode_type type
; /* polynomial or periodic or evector */
58 int size
; /* number of attached pointers */
59 int pos
; /* parameter position */
60 evalue arr
[1]; /* array of rational/pointer */
63 typedef struct _enumeration
{
65 Polyhedron
*ValidityDomain
; /* contraints on the parameters */
66 evalue EP
; /* dimension = combined space */
67 struct _enumeration
*next
; /* Ehrhart Polynomial, corresponding
68 to parameter values inside the
69 domain ValidityDomain below */
73 void evalue_set_si(evalue
*ev
, int n
, int d
);
74 void evalue_set(evalue
*ev
, Value n
, Value d
);
75 void evalue_copy(evalue
*dst
, const evalue
*src
);
76 evalue
*evalue_zero();
77 enode
*new_enode(enode_type type
,int size
,int pos
);
78 enode
*ecopy(enode
*e
);
79 int eequal(evalue
*e1
,evalue
*e2
);
80 void free_evalue_refs(evalue
*e
);
81 void print_evalue(FILE *DST
,evalue
*e
,char **pname
);
82 void print_enode(FILE *DST
,enode
*p
,char **pname
);
83 void reduce_evalue (evalue
*e
);
84 void reduce_evalue_in_domain(evalue
*e
, Polyhedron
*D
);
85 void aep_evalue(evalue
*e
, int *ref
);
86 void addeliminatedparams_evalue(evalue
*e
,Matrix
*CT
);
87 void addeliminatedparams_enum(evalue
*e
, Matrix
*CT
, Polyhedron
*CEq
,
88 unsigned MaxRays
, unsigned nparam
);
89 void eadd(const evalue
*e1
, evalue
*res
);
90 void emul (evalue
*e1
, evalue
*res
);
91 void emask(evalue
*mask
, evalue
*res
);
92 int in_domain(Polyhedron
*P
, Value
*list_args
);
93 double compute_evalue(evalue
*e
,Value
*list_args
);
94 Value
*compute_poly(Enumeration
*en
,Value
*list_args
);
95 void evalue_mod2table(evalue
*ev
, int nparam
);
96 void evalue_mod2relation(evalue
*e
);
97 void evalue_combine(evalue
*e
);
98 void evalue_range_reduction(evalue
*e
);
99 int evalue_range_reduction_in_domain(evalue
*e
, Polyhedron
*D
);
100 size_t evalue_size(evalue
*e
);
101 size_t domain_size(Polyhedron
*D
);
102 Enumeration
* partition2enumeration(evalue
*EP
);
103 void evalue_frac2floor(evalue
*e
);
104 int evalue_frac2floor_in_domain(evalue
*e
, Polyhedron
*D
);
105 void evalue_frac2floor2(evalue
*e
, int shift
);
106 int evalue_frac2floor_in_domain3(evalue
*e
, Polyhedron
*D
, int shift
);
107 evalue
*esum(evalue
*E
, int nvar
);
108 void eor(evalue
*e1
, evalue
*res
);
109 void evalue_denom(evalue
*e
, Value
*d
);
111 #if defined(__cplusplus)