15#include <isl_config.h>
37#define GBR_init(v) mpq_init(v)
38#define GBR_clear(v) mpq_clear(v)
39#define GBR_set(a,b) mpq_set(a,b)
40#define GBR_set_ui(a,b) mpq_set_ui(a,b,1)
41#define GBR_mul(a,b,c) mpq_mul(a,b,c)
42#define GBR_lt(a,b) (mpq_cmp(a,b) < 0)
43#define GBR_is_zero(a) (mpq_sgn(a) == 0)
44#define GBR_numref(a) mpq_numref(a)
45#define GBR_denref(a) mpq_denref(a)
46#define GBR_floor(a,b) mpz_fdiv_q(a,GBR_numref(b),GBR_denref(b))
47#define GBR_ceil(a,b) mpz_cdiv_q(a,GBR_numref(b),GBR_denref(b))
48#define GBR_set_num_neg(a, b) mpz_neg(GBR_numref(*a), b);
49#define GBR_set_den(a, b) mpz_set(GBR_denref(*a), b);
52#ifdef USE_IMATH_FOR_MP
55#define GBR_type mp_rat
56#define GBR_init(v) v = mp_rat_alloc()
57#define GBR_clear(v) mp_rat_free(v)
58#define GBR_set(a,b) mp_rat_copy(b,a)
59#define GBR_set_ui(a,b) mp_rat_set_uvalue(a,b,1)
60#define GBR_mul(a,b,c) mp_rat_mul(b,c,a)
61#define GBR_lt(a,b) (mp_rat_compare(a,b) < 0)
62#define GBR_is_zero(a) (mp_rat_compare_zero(a) == 0)
63#ifdef USE_SMALL_INT_OPT
64#define GBR_numref(a) isl_sioimath_encode_big(mp_rat_numer_ref(a))
65#define GBR_denref(a) isl_sioimath_encode_big(mp_rat_denom_ref(a))
66#define GBR_floor(a, b) isl_sioimath_fdiv_q((a), GBR_numref(b), GBR_denref(b))
67#define GBR_ceil(a, b) isl_sioimath_cdiv_q((a), GBR_numref(b), GBR_denref(b))
68#define GBR_set_num_neg(a, b) \
70 isl_sioimath_scratchspace_t scratch; \
71 impz_neg(mp_rat_numer_ref(*a), \
72 isl_sioimath_bigarg_src(*b, &scratch));\
74#define GBR_set_den(a, b) \
76 isl_sioimath_scratchspace_t scratch; \
77 impz_set(mp_rat_denom_ref(*a), \
78 isl_sioimath_bigarg_src(*b, &scratch));\
81#define GBR_numref(a) mp_rat_numer_ref(a)
82#define GBR_denref(a) mp_rat_denom_ref(a)
83#define GBR_floor(a,b) impz_fdiv_q(a,GBR_numref(b),GBR_denref(b))
84#define GBR_ceil(a,b) impz_cdiv_q(a,GBR_numref(b),GBR_denref(b))
85#define GBR_set_num_neg(a, b) impz_neg(GBR_numref(*a), b)
86#define GBR_set_den(a, b) impz_set(GBR_denref(*a), b)
100#define GBR_LP struct tab_lp
101#define GBR_lp_init(P) init_lp(P)
102#define GBR_lp_set_obj(lp, obj, dim) set_lp_obj(lp, obj, dim)
103#define GBR_lp_solve(lp) solve_lp(lp)
104#define GBR_lp_get_obj_val(lp, F) get_obj_val(lp, F)
105#define GBR_lp_delete(lp) delete_lp(lp)
106#define GBR_lp_next_row(lp) lp->neq
107#define GBR_lp_add_row(lp, row, dim) add_lp_row(lp, row, dim)
108#define GBR_lp_get_alpha(lp, row, alpha) get_alpha(lp, row, alpha)
109#define GBR_lp_del_row(lp) del_lp_row(lp)
110#define GBR_lp_is_fixed(lp) (lp)->is_fixed
111#define GBR_lp_cut(lp, obj) cut_lp_to_hyperplane(lp, obj)
211 "unexpected missing (bounded) solution",
return -1);
248 GBR_set_num_neg(F, lp->
opt);
285 GBR_set_num_neg(alpha, lp->
tab->
dual->
el[1 + row]);
286 GBR_set_den(alpha, lp->
tab->
dual->
el[0]);
static void get_alpha(struct tab_lp *lp, int row, GBR_type *alpha)
static void delete_lp(struct tab_lp *lp)
static void get_obj_val(struct tab_lp *lp, GBR_type *F)
static int del_lp_row(struct tab_lp *lp) WARN_UNUSED
static int cut_lp_to_hyperplane(struct tab_lp *lp, isl_int *row)
static int add_lp_row(struct tab_lp *lp, isl_int *row, int dim)
static struct tab_lp * init_lp(struct isl_tab *tab)
static struct isl_tab * gbr_tab(struct isl_tab *tab, struct isl_vec *row)
static void set_lp_obj(struct tab_lp *lp, isl_int *row, int dim)
static int solve_lp(struct tab_lp *lp)
#define isl_calloc_type(ctx, type)
#define isl_die(ctx, errno, msg, code)
void isl_ctx_deref(struct isl_ctx *ctx)
#define isl_alloc_array(ctx, type, n)
void isl_ctx_ref(struct isl_ctx *ctx)
#define isl_int_divexact_ui(r, i, j)
#define isl_int_neg(r, i)
#define isl_int_abs_lt(i, j)
#define isl_int_cdiv_q(r, i, j)
#define isl_int_mul_ui(r, i, j)
#define isl_int_set_si(r, i)
#define isl_int_fdiv_q(r, i, j)
void isl_seq_inner_product(isl_int *p1, isl_int *p2, unsigned len, isl_int *prod)
void isl_seq_clr(isl_int *p, unsigned len)
void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len)
void isl_seq_neg(isl_int *dst, isl_int *src, unsigned len)
void isl_tab_free(struct isl_tab *tab)
struct isl_tab * isl_tab_product(struct isl_tab *tab1, struct isl_tab *tab2)
isl_stat isl_tab_add_eq(struct isl_tab *tab, isl_int *eq)
struct isl_tab_undo * isl_tab_snap(struct isl_tab *tab)
__isl_give isl_vec * isl_tab_get_sample_value(struct isl_tab *tab)
int isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq)
enum isl_lp_result isl_tab_min(struct isl_tab *tab, isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom, unsigned flags)
isl_stat isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap)
int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new)
#define ISL_TAB_SAVE_DUAL
struct isl_tab_undo ** stack
__isl_null isl_vec * isl_vec_free(__isl_take isl_vec *vec)
__isl_give isl_vec * isl_vec_alloc(isl_ctx *ctx, unsigned size)