diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-11 23:08:40 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-11 23:08:40 +0000 |
commit | f857b833ca35d9f7de4ca5bd69a6a6bfbb3c5cdb (patch) | |
tree | 87813bf13316717ad3c1a7df9dff9f66d1e355f1 /tests/tfma.c | |
parent | 4d3b2f84f7aab46dd93331cf355fecf725d0a043 (diff) | |
download | mpfr-f857b833ca35d9f7de4ca5bd69a6a6bfbb3c5cdb.tar.gz |
[tests/tfma.c] GNU coding style.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9561 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tfma.c')
-rw-r--r-- | tests/tfma.c | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/tests/tfma.c b/tests/tfma.c index 1016a57c7..e65655b79 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -634,81 +634,81 @@ main (int argc, char *argv[]) int inexact, compare; unsigned int n; - mpfr_prec_t p0=2, p1=200; - unsigned int N=200; + mpfr_prec_t p0 = 2, p1 = 200; + unsigned int N = 200; mpfr_init (t); mpfr_init (slong); /* generic test */ for (prec = p0; prec <= p1; prec++) - { - mpfr_set_prec (x, prec); - mpfr_set_prec (y, prec); - mpfr_set_prec (z, prec); - mpfr_set_prec (s, prec); - mpfr_set_prec (t, prec); + { + mpfr_set_prec (x, prec); + mpfr_set_prec (y, prec); + mpfr_set_prec (z, prec); + mpfr_set_prec (s, prec); + mpfr_set_prec (t, prec); - for (n=0; n<N; n++) - { - mpfr_urandomb (x, RANDS); - mpfr_urandomb (y, RANDS); - mpfr_urandomb (z, RANDS); - - if (randlimb () % 2) - mpfr_neg (x, x, MPFR_RNDN); - if (randlimb () % 2) - mpfr_neg (y, y, MPFR_RNDN); - if (randlimb () % 2) - mpfr_neg (z, z, MPFR_RNDN); - - rnd = RND_RAND (); - mpfr_set_prec (slong, 2 * prec); - if (mpfr_mul (slong, x, y, rnd)) - { - printf ("x*y should be exact\n"); - exit (1); - } - compare = mpfr_add (t, slong, z, rnd); - inexact = mpfr_fma (s, x, y, z, rnd); - if (mpfr_cmp (s, t)) - { - printf ("results differ for x="); - mpfr_out_str (stdout, 2, prec, x, MPFR_RNDN); - printf (" y="); - mpfr_out_str (stdout, 2, prec, y, MPFR_RNDN); - printf (" z="); - mpfr_out_str (stdout, 2, prec, z, MPFR_RNDN); - printf (" prec=%u rnd_mode=%s\n", (unsigned int) prec, - mpfr_print_rnd_mode (rnd)); - printf ("got "); - mpfr_out_str (stdout, 2, prec, s, MPFR_RNDN); - puts (""); - printf ("expected "); - mpfr_out_str (stdout, 2, prec, t, MPFR_RNDN); - puts (""); - printf ("approx "); - mpfr_print_binary (slong); - puts (""); - exit (1); - } - if (((inexact == 0) && (compare != 0)) || - ((inexact < 0) && (compare >= 0)) || - ((inexact > 0) && (compare <= 0))) - { - printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", - mpfr_print_rnd_mode (rnd), compare, inexact); - printf (" x="); mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); - printf (" y="); mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN); - printf (" z="); mpfr_out_str (stdout, 2, 0, z, MPFR_RNDN); - printf (" s="); mpfr_out_str (stdout, 2, 0, s, MPFR_RNDN); - printf ("\n"); - exit (1); - } - } - } - mpfr_clear (t); - mpfr_clear (slong); + for (n = 0; n < N; n++) + { + mpfr_urandomb (x, RANDS); + mpfr_urandomb (y, RANDS); + mpfr_urandomb (z, RANDS); + + if (randlimb () % 2) + mpfr_neg (x, x, MPFR_RNDN); + if (randlimb () % 2) + mpfr_neg (y, y, MPFR_RNDN); + if (randlimb () % 2) + mpfr_neg (z, z, MPFR_RNDN); + + rnd = RND_RAND (); + mpfr_set_prec (slong, 2 * prec); + if (mpfr_mul (slong, x, y, rnd)) + { + printf ("x*y should be exact\n"); + exit (1); + } + compare = mpfr_add (t, slong, z, rnd); + inexact = mpfr_fma (s, x, y, z, rnd); + if (mpfr_cmp (s, t)) + { + printf ("results differ for x="); + mpfr_out_str (stdout, 2, prec, x, MPFR_RNDN); + printf (" y="); + mpfr_out_str (stdout, 2, prec, y, MPFR_RNDN); + printf (" z="); + mpfr_out_str (stdout, 2, prec, z, MPFR_RNDN); + printf (" prec=%u rnd_mode=%s\n", (unsigned int) prec, + mpfr_print_rnd_mode (rnd)); + printf ("got "); + mpfr_out_str (stdout, 2, prec, s, MPFR_RNDN); + puts (""); + printf ("expected "); + mpfr_out_str (stdout, 2, prec, t, MPFR_RNDN); + puts (""); + printf ("approx "); + mpfr_print_binary (slong); + puts (""); + exit (1); + } + if (((inexact == 0) && (compare != 0)) || + ((inexact < 0) && (compare >= 0)) || + ((inexact > 0) && (compare <= 0))) + { + printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", + mpfr_print_rnd_mode (rnd), compare, inexact); + printf (" x="); mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); + printf (" y="); mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN); + printf (" z="); mpfr_out_str (stdout, 2, 0, z, MPFR_RNDN); + printf (" s="); mpfr_out_str (stdout, 2, 0, s, MPFR_RNDN); + printf ("\n"); + exit (1); + } + } + } + mpfr_clear (t); + mpfr_clear (slong); } mpfr_clear (x); |