diff options
author | Sven Verdoolaege <skimo@kotnet.org> | 2008-08-07 20:45:58 +0200 |
---|---|---|
committer | Sven Verdoolaege <skimo@kotnet.org> | 2008-08-08 01:18:28 +0200 |
commit | cc726006058136865f8c2f496d3df57b9f937ea5 (patch) | |
tree | bd32e2394f8d0009e026595b1b328ee6311d057c /isl_lp_piplib.c | |
download | isl-cc726006058136865f8c2f496d3df57b9f937ea5.tar.gz isl-cc726006058136865f8c2f496d3df57b9f937ea5.tar.bz2 isl-cc726006058136865f8c2f496d3df57b9f937ea5.zip |
Initial version of the integer set library
This version is very incomplete and unoptimized.
Diffstat (limited to 'isl_lp_piplib.c')
-rw-r--r-- | isl_lp_piplib.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/isl_lp_piplib.c b/isl_lp_piplib.c new file mode 100644 index 00000000..0072295d --- /dev/null +++ b/isl_lp_piplib.c @@ -0,0 +1,52 @@ +#include "isl_map.h" +#include "isl_lp.h" +#include "isl_piplib.h" +#include "isl_map_piplib.h" + +enum isl_lp_result isl_pip_solve_lp(struct isl_basic_map *bmap, int maximize, + isl_int *f, isl_int denom, isl_int *opt) +{ + enum isl_lp_result res = isl_lp_ok; + PipMatrix *domain = NULL; + PipOptions *options; + PipQuast *sol; + unsigned total; + + total = bmap->nparam + bmap->n_in + bmap->n_out + bmap->n_div; + domain = isl_basic_map_to_pip(bmap, 0, 1, 0); + if (!domain) + goto error; + entier_set_si(domain->p[0][1], -1); + isl_seq_cpy_to_pip(domain->p[0]+2, f, total); + + options = pip_options_init(); + if (!options) + goto error; + options->Urs_unknowns = -1; + options->Maximize = maximize; + options->Nq = 0; + sol = pip_solve(domain, NULL, -1, options); + pip_options_free(options); + if (!sol) + goto error; + + if (!sol->list) + res = isl_lp_empty; + else if (entier_zero_p(sol->list->vector->the_deno[0])) + res = isl_lp_unbounded; + else { + if (maximize) + mpz_fdiv_q(*opt, sol->list->vector->the_vector[0], + sol->list->vector->the_deno[0]); + else + mpz_cdiv_q(*opt, sol->list->vector->the_vector[0], + sol->list->vector->the_deno[0]); + } + pip_matrix_free(domain); + pip_quast_free(sol); + return res; +error: + if (domain) + pip_matrix_free(domain); + return isl_lp_error; +} |