From b073a8206cb156e5dfc540e6a14125f90a9f66e5 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 31 Mar 2007 14:23:16 +0200 Subject: [PATCH] use separate flags option for scale approximation method --- barvinok/options.h | 8 +++++--- options.c | 33 +++++++++++++++++++++++++++++---- scale.c | 3 +-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/barvinok/options.h b/barvinok/options.h index 39997b3..5453ff5 100644 --- a/barvinok/options.h +++ b/barvinok/options.h @@ -46,9 +46,10 @@ struct barvinok_options { int polynomial_approximation; #define BV_APPROX_NONE 0 #define BV_APPROX_DROP 1 - #define BV_APPROX_SCALE_FAST 2 - #define BV_APPROX_SCALE 3 + #define BV_APPROX_SCALE 2 int approximation_method; + #define BV_APPROX_SCALE_FAST (1 << 0) + int scale_flags; /* basis reduction options */ #define BV_GBR_NONE 0 @@ -79,7 +80,8 @@ void barvinok_options_free(struct barvinok_options *options); #define BV_OPT_MAXINDEX 260 #define BV_OPT_POLAPPROX 261 #define BV_OPT_APPROX 262 -#define BV_OPT_LAST 262 +#define BV_OPT_SCALE 263 +#define BV_OPT_LAST 263 struct argp; extern struct argp barvinok_argp; diff --git a/options.c b/options.c index bae6ac4..37b2348 100644 --- a/options.c +++ b/options.c @@ -92,6 +92,17 @@ void barvinok_options_free(struct barvinok_options *options) free(options); } +enum { + SCALE_FAST, + SCALE_SLOW +}; + +const char *scale_opts[] = { + "fast", + "slow", + NULL +}; + struct argp_option barvinok_argp_options[] = { { "index", BV_OPT_MAXINDEX, "int", 0, "maximal index of simple cones in decomposition" }, @@ -99,8 +110,9 @@ struct argp_option barvinok_argp_options[] = { { "table", BV_OPT_TABLE, 0, 0 }, { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 }, { "polynomial-approximation", BV_OPT_POLAPPROX, "lower|upper", 1 }, - { "approximation-method", BV_OPT_APPROX, "scale|scale-fast|drop", 0, + { "approximation-method", BV_OPT_APPROX, "scale|drop", 0, "method to use in polynomial approximation [default: drop]" }, + { "scale-options", BV_OPT_SCALE, "fast|slow", 0 }, { "gbr", BV_OPT_GBR, "[cdd]", 0, "solver to use for basis reduction" }, { "version", 'V', 0, 0 }, @@ -110,6 +122,7 @@ struct argp_option barvinok_argp_options[] = { error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state) { struct barvinok_options *options = state->input; + char *subopt; switch (key) { case 'V': @@ -140,7 +153,7 @@ error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state) if (!arg) { options->polynomial_approximation = BV_APPROX_SIGN_APPROX; if (options->approximation_method == BV_APPROX_NONE) - options->approximation_method = BV_APPROX_SCALE_FAST; + options->approximation_method = BV_APPROX_SCALE; } else { if (!strcmp(arg, "lower")) options->polynomial_approximation = BV_APPROX_SIGN_LOWER; @@ -153,11 +166,23 @@ error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state) case BV_OPT_APPROX: if (!strcmp(arg, "scale")) options->approximation_method = BV_APPROX_SCALE; - else if (!strcmp(arg, "scale-fast")) - options->approximation_method = BV_APPROX_SCALE_FAST; else if (!strcmp(arg, "drop")) options->approximation_method = BV_APPROX_DROP; break; + case BV_OPT_SCALE: + options->approximation_method = BV_APPROX_SCALE; + while (*arg != '\0') + switch (getsubopt(&arg, scale_opts, &subopt)) { + case SCALE_FAST: + options->scale_flags |= BV_APPROX_SCALE_FAST; + break; + case SCALE_SLOW: + options->scale_flags &= ~BV_APPROX_SCALE_FAST; + break; + default: + argp_error(state, "unknown suboption '%s'\n", subopt); + } + break; case ARGP_KEY_END: if (options->polynomial_approximation == BV_APPROX_SIGN_APPROX && options->approximation_method == BV_APPROX_DROP) diff --git a/scale.c b/scale.c index 85b564e..1bdf6e4 100644 --- a/scale.c +++ b/scale.c @@ -295,9 +295,8 @@ Polyhedron *scale(Param_Polyhedron *PP, Polyhedron *P, struct barvinok_options *options) { Polyhedron *T = P; - int scale_fast = options->approximation_method == BV_APPROX_SCALE_FAST; - if (scale_fast) + if (options->scale_flags & BV_APPROX_SCALE_FAST) Param_Polyhedron_Scale_Integer(PP, &T, &scaling->det, options->MaxRays); else Param_Polyhedron_Scale_Integer_Slow(PP, &T, &scaling->det, options->MaxRays); -- 2.11.4.GIT