if (i < total)
return 0;
- res = isl_solve_lp(*bmap, 0, c+1, (*bmap)->ctx->one, opt_n, opt_d);
+ res = isl_solve_lp(*bmap, 0, c, (*bmap)->ctx->one, opt_n, opt_d);
if (res == isl_lp_unbounded)
return 0;
if (res == isl_lp_error)
*bmap = isl_basic_map_set_to_empty(*bmap);
return 0;
}
- if (opt_d)
- isl_int_addmul(*opt_n, *opt_d, c[0]);
- else
- isl_int_add(*opt_n, *opt_n, c[0]);
return !isl_int_is_neg(*opt_n);
}
continue;
res = isl_solve_lp((struct isl_basic_map*)set->p[j],
- 0, c+1, ctx->one, &opt, &opt_denom);
+ 0, c, ctx->one, &opt, &opt_denom);
if (res == isl_lp_unbounded)
break;
if (res == isl_lp_error)
}
if (!isl_int_is_one(opt_denom))
isl_seq_scale(c, c, opt_denom, len);
- if (first || isl_int_lt(opt, c[0]))
- isl_int_set(c[0], opt);
+ if (first || isl_int_is_neg(opt))
+ isl_int_sub(c[0], c[0], opt);
first = 0;
}
isl_int_clear(opt);
isl_int_clear(opt_denom);
- isl_int_neg(c[0], c[0]);
return j >= set->n;
error:
isl_int_clear(opt);
if (!set)
goto error;
lp = wrap_constraints(set);
- obj = isl_vec_alloc(set->ctx, dim*set->n);
+ obj = isl_vec_alloc(set->ctx, 1 + dim*set->n);
if (!obj)
goto error;
+ isl_int_set_si(obj->block.data[0], 0);
for (i = 0; i < set->n; ++i) {
- isl_seq_clr(obj->block.data+dim*i, 2);
- isl_int_set_si(obj->block.data[dim*i+2], 1);
- isl_seq_clr(obj->block.data+dim*i+3, dim-3);
+ isl_seq_clr(obj->block.data + 1 + dim*i, 2);
+ isl_int_set_si(obj->block.data[1 + dim*i+2], 1);
+ isl_seq_clr(obj->block.data + 1 + dim*i+3, dim-3);
}
isl_int_init(num);
isl_int_init(den);
#include "isl_lp.h"
#include "isl_lp_piplib.h"
+/* Given a basic map "bmap" and an affine combination of the variables "f"
+ * with denominator "denom", set *opt/*opt_denom to the minimal
+ * (or maximal if "maximize" is true) value attained by f/d over "bmap",
+ * assuming the basic map is not empty and the expression cannot attain
+ * arbitrarily small (or large) values.
+ * If opt_denom is NULL, then *opt is rounded up (or down)
+ * to the nearest integer.
+ * The return value reflects the nature of the result (empty, unbounded,
+ * minmimal or maximal value returned in *opt).
+ */
enum isl_lp_result isl_solve_lp(struct isl_basic_map *bmap, int maximize,
isl_int *f, isl_int denom, isl_int *opt,
isl_int *opt_denom)
goto error;
total = isl_basic_map_total_dim(bmap1);
ctx = bmap1->ctx;
- obj = isl_vec_alloc(ctx, total);
- isl_seq_clr(obj->block.data, total);
- isl_int_set_si(obj->block.data[nparam+pos], 1);
- isl_int_set_si(obj->block.data[nparam+pos+(dim1-pos)], -1);
+ obj = isl_vec_alloc(ctx, 1 + total);
+ isl_seq_clr(obj->block.data, 1 + total);
+ isl_int_set_si(obj->block.data[1+nparam+pos], 1);
+ isl_int_set_si(obj->block.data[1+nparam+pos+(dim1-pos)], -1);
if (!obj)
goto error;
isl_int_init(num);