From 1815e17b4243a3973e1389f73fe1607ec42f5372 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 28 Oct 2010 16:43:26 -0400 Subject: Benchmark multiple degrees of polynomials. --- bench/libdimension/polynomial.c | 46 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'bench/libdimension') diff --git a/bench/libdimension/polynomial.c b/bench/libdimension/polynomial.c index 5b8921c..bcf9281 100644 --- a/bench/libdimension/polynomial.c +++ b/bench/libdimension/polynomial.c @@ -24,14 +24,38 @@ int main(void) { - double poly[6], x[5]; - // poly[] = (x + 1)*(x - 1.2345)*(x - 2.3456)*(x - 5)*(x - 100) - poly[5] = 1.0; - poly[4] = -107.5801; - poly[3] = 770.2260432; - poly[2] = -1215.2863928; - poly[1] = -646.270936; - poly[0] = 1447.8216; +#define NPOLY 5 + double p[NPOLY][NPOLY + 1], x[NPOLY]; + + // p[0][] = x - 0.5; + p[0][1] = 1.0; + p[0][0] = -0.5; + + // p[1][] = (x + 0.5)*(x - 0.5) + p[1][2] = 1.0; + p[1][1] = 0.0; + p[1][0] = -0.25; + + // p[2][] = (x + 1)*(x - 1.2345)*(x - 100) + p[2][3] = 1.0; + p[2][2] = -100.2345; + p[2][1] = 22.2155; + p[2][0] = 123.45; + + // p[3][] = (x + 1)*(x - 1.2345)*(x - 5)*(x - 100) + p[3][4] = 1.0; + p[3][3] = -105.2345; + p[3][2] = 523.388; + p[3][1] = 12.3725; + p[3][0] = -617.25; + + // p[4][] = (x + 1)*(x - 1.2345)*(x - 2.3456)*(x - 5)*(x - 100) + p[4][5] = 1.0; + p[4][4] = -107.5801; + p[4][3] = 770.2260432; + p[4][2] = -1215.2863928; + p[4][1] = -646.270936; + p[4][0] = 1447.8216; sandglass_t sandglass; if (sandglass_init_monotonic(&sandglass, SANDGLASS_CPUTIME) != 0) { @@ -39,8 +63,10 @@ main(void) return EXIT_FAILURE; } - sandglass_bench_fine(&sandglass, dmnsn_solve_polynomial(poly, 5, x)); - printf("dmnsn_solve_polynomial(): %ld\n", sandglass.grains); + for (size_t i = 0; i < NPOLY; ++i) { + sandglass_bench_fine(&sandglass, dmnsn_solve_polynomial(p[i], i + 1, x)); + printf("dmnsn_solve_polynomial(x^%zu): %ld\n", i + 1, sandglass.grains); + } return EXIT_SUCCESS; } -- cgit v1.2.3