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
32 #define evalue_div _new_evalue_div
34 typedef enum { polynomial
, periodic
, evector
, fractional
, relation
,
35 partition
, flooring
} enode_type
;
37 typedef struct _evalue
{
38 Value d
; /* denominator */
40 Value n
; /* numerator (if denominator > 0) */
41 struct _enode
*p
; /* pointer (if denominator == 0) */
42 Polyhedron
*D
; /* domain (if denominator == -1) */
46 #define EVALUE_DOMAIN(ev) ((ev).x.D)
47 #define EVALUE_SET_DOMAIN(ev, D) \
49 value_set_si((ev).d, -1); \
50 EVALUE_DOMAIN(ev) = D; \
52 #define EVALUE_IS_DOMAIN(ev) (value_mone_p((ev).d))
54 #define EVALUE_IS_ZERO(ev) (value_pos_p((ev).d) && value_zero_p((ev).x.n))
55 #define EVALUE_IS_ONE(ev) (value_one_p((ev).d) && value_one_p((ev).x.n))
57 typedef struct _enode
{
58 enode_type type
; /* polynomial or periodic or evector */
59 int size
; /* number of attached pointers */
60 int pos
; /* parameter position */
61 evalue arr
[1]; /* array of rational/pointer */
64 typedef struct _enumeration
{
66 Polyhedron
*ValidityDomain
; /* contraints on the parameters */
67 evalue EP
; /* dimension = combined space */
68 struct _enumeration
*next
; /* Ehrhart Polynomial, corresponding
69 to parameter values inside the
70 domain ValidityDomain below */
74 void evalue_set_si(evalue
*ev
, int n
, int d
);
75 void evalue_set(evalue
*ev
, Value n
, Value d
);
76 void evalue_copy(evalue
*dst
, const evalue
*src
);
77 evalue
*evalue_zero();
78 enode
*new_enode(enode_type type
,int size
,int pos
);
79 enode
*ecopy(enode
*e
);
80 int eequal(evalue
*e1
,evalue
*e2
);
81 void free_evalue_refs(evalue
*e
);
82 void print_evalue(FILE *DST
,evalue
*e
,char **pname
);
83 void print_enode(FILE *DST
,enode
*p
,char **pname
);
84 void reduce_evalue (evalue
*e
);
85 void reduce_evalue_in_domain(evalue
*e
, Polyhedron
*D
);
86 void aep_evalue(evalue
*e
, int *ref
);
87 void addeliminatedparams_evalue(evalue
*e
,Matrix
*CT
);
88 void addeliminatedparams_enum(evalue
*e
, Matrix
*CT
, Polyhedron
*CEq
,
89 unsigned MaxRays
, unsigned nparam
);
90 void eadd(const evalue
*e1
, evalue
*res
);
91 void emul (evalue
*e1
, evalue
*res
);
92 void emask(evalue
*mask
, evalue
*res
);
93 int in_domain(Polyhedron
*P
, Value
*list_args
);
94 double compute_evalue(evalue
*e
,Value
*list_args
);
95 Value
*compute_poly(Enumeration
*en
,Value
*list_args
);
96 void evalue_mod2table(evalue
*ev
, int nparam
);
97 void evalue_mod2relation(evalue
*e
);
98 void evalue_combine(evalue
*e
);
99 void evalue_range_reduction(evalue
*e
);
100 int evalue_range_reduction_in_domain(evalue
*e
, Polyhedron
*D
);
101 size_t evalue_size(evalue
*e
);
102 size_t domain_size(Polyhedron
*D
);
103 Enumeration
* partition2enumeration(evalue
*EP
);
104 void evalue_frac2floor(evalue
*e
);
105 int evalue_frac2floor_in_domain(evalue
*e
, Polyhedron
*D
);
106 void evalue_frac2floor2(evalue
*e
, int shift
);
107 int evalue_frac2floor_in_domain3(evalue
*e
, Polyhedron
*D
, int shift
);
108 evalue
*esum(evalue
*E
, int nvar
);
109 void eor(evalue
*e1
, evalue
*res
);
110 void evalue_denom(evalue
*e
, Value
*d
);
111 void evalue_div(evalue
* e
, Value n
);
112 void evalue_split_domains_into_orthants(evalue
*e
, unsigned MaxRays
);
114 #if defined(__cplusplus)