From 37229787cad86421edb4a9e8472e487917f78c7b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 13 Apr 2007 01:38:06 +0200 Subject: [PATCH] volume.c: keep track of number of simplices in volume computation --- barvinok/options.h | 1 + options.c | 3 +++ volume.c | 14 ++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/barvinok/options.h b/barvinok/options.h index fdd82f4..79a8c11 100644 --- a/barvinok/options.h +++ b/barvinok/options.h @@ -9,6 +9,7 @@ extern "C" { struct barvinok_stats { long base_cones; + long volume_simplices; }; void barvinok_stats_clear(struct barvinok_stats *stats); diff --git a/options.c b/options.c index f332a09..518c43c 100644 --- a/options.c +++ b/options.c @@ -22,11 +22,14 @@ Vector *Polyhedron_Sample(Polyhedron *P, struct barvinok_options *options) void barvinok_stats_clear(struct barvinok_stats *stats) { stats->base_cones = 0; + stats->volume_simplices = 0; } void barvinok_stats_print(struct barvinok_stats *stats, FILE *out) { fprintf(out, "Base cones: %d\n", stats->base_cones); + if (stats->volume_simplices) + fprintf(out, "Volume simplices: %d\n", stats->volume_simplices); } struct barvinok_options *barvinok_options_new_with_defaults() diff --git a/volume.c b/volume.c index 7b62079..0c5f30a 100644 --- a/volume.c +++ b/volume.c @@ -421,13 +421,15 @@ static evalue *volume_triangulate(Param_Polyhedron *PP, Param_Domain *D, static evalue *volume_simplex(Param_Polyhedron *PP, Param_Domain *D, unsigned dim, evalue ***matrix, struct parameter_point *point, - int row, unsigned MaxRays) + int row, struct barvinok_options *options) { evalue mone; Param_Vertices *V; evalue *vol, *val; int i, j; + options->stats->volume_simplices++; + value_init(mone.d); evalue_set_si(&mone, -1, 1); @@ -471,7 +473,7 @@ static evalue *volume_simplex(Param_Polyhedron *PP, Param_Domain *D, static evalue *volume_triangulate_lift(Param_Polyhedron *PP, Param_Domain *D, unsigned dim, evalue ***matrix, struct parameter_point *point, - int row, unsigned MaxRays) + int row, struct barvinok_options *options) { const static int MAX_TRY=10; Param_Vertices *V; @@ -529,7 +531,7 @@ try_again: value_set_si(FixedRays->p[i][1+dim], random_int((t+1)*dim*nbV)+1); M = Matrix_Copy(FixedRays); - L = Rays2Polyhedron(M, MaxRays); + L = Rays2Polyhedron(M, options->MaxRays); Matrix_Free(M); POL_ENSURE_FACETS(L); @@ -554,7 +556,7 @@ try_again: END_FORALL_PVertex_in_ParamPolyhedron; assert(r == (dim-row)+1); - s = volume_simplex(PP, &SD, dim, matrix, point, row, MaxRays); + s = volume_simplex(PP, &SD, dim, matrix, point, row, options); if (!vol) vol = s; else { @@ -591,13 +593,13 @@ static evalue *volume_in_domain(Param_Polyhedron *PP, Param_Domain *D, if (nbV > (dim-row) + 1) { if (options->volume_triangulate == BV_VOL_LIFT) vol = volume_triangulate_lift(PP, D, dim, matrix, point, - row, options->MaxRays); + row, options); else vol = volume_triangulate(PP, D, dim, matrix, point, row, F, options); } else { assert(nbV == (dim-row) + 1); - vol = volume_simplex(PP, D, dim, matrix, point, row, options->MaxRays); + vol = volume_simplex(PP, D, dim, matrix, point, row, options); } return vol; -- 2.11.4.GIT