diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-09-24 10:14:20 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-09-24 10:14:20 +0000 |
commit | 638b0e723a5f7891b69bdde938fe625a18e52f22 (patch) | |
tree | b88e3071adb41426387ca1550e6223061a5aad29 /tests/tfr_div.c | |
parent | cf0287be2d1f292ba808ea1de011195ac8dd5a24 (diff) | |
download | mpc-638b0e723a5f7891b69bdde938fe625a18e52f22.tar.gz |
src/fr_sub.c: Fix bug revealed by tests (wrong sign in imaginary part).
tests/tgeneric_cfc.c: random tests for complex functions of two variables : the first one of type mpfr_t and the second one of type mpc_t; and tests for parameter reuse.
tests/Makefile.am: add tgeneric_cfc.c to EXTRA_DIST and add new tests files.
tests/tfr_div.c tests/tfr_sub.c: use tgeneric_cfc.c
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@196 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tfr_div.c')
-rw-r--r-- | tests/tfr_div.c | 67 |
1 files changed, 19 insertions, 48 deletions
diff --git a/tests/tfr_div.c b/tests/tfr_div.c index 19c6d5e..1d9dd0e 100644 --- a/tests/tfr_div.c +++ b/tests/tfr_div.c @@ -1,4 +1,4 @@ -/* tfr_div -- test file for mpc_div. +/* tfr_div -- test file for mpc_fr_div. Copyright (C) 2008 Philippe Th\'eveny @@ -20,60 +20,31 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdio.h> +#include <stdlib.h> #include "gmp.h" #include "mpfr.h" #include "mpc.h" -#include "random.c" - -static void -check_random (void) -{ - mpc_t b, c, q, q_ref; - mp_prec_t prec; - mp_rnd_t rnd_re, rnd_im; - mpc_rnd_t rnd; - mpc_init (b); - mpc_init (c); - mpc_init (q); - mpc_init (q_ref); +static int +mpc_fr_div_ref (mpc_t q, mpfr_t x, mpc_t z, mpc_rnd_t rnd); - for (prec = 2; prec < 1024; prec++) - { - mpc_set_prec (b, prec); - mpc_set_prec (c, prec); - mpc_set_prec (q, prec); - mpc_set_prec (q_ref, prec); +#include "random.c" +#define TEST_FUNCTION mpc_fr_div +#define REFERENCE_FUNCTION mpc_fr_div_ref +#include "tgeneric_cfc.c" - test_default_random (c, -8192, 8192, 1); - test_default_random (b, -65535, 65535, 1); - mpfr_set_ui (MPC_IM (b), 0, GMP_RNDN); +static int +mpc_fr_div_ref (mpc_t q, mpfr_t x, mpc_t z, mpc_rnd_t rnd) +{ + int inexact; + mpc_t y; + mpc_init2 (y, MPFR_PREC (x)); + mpc_set_fr (y, x, MPC_RNDNN); - for (rnd_re = (mp_rnd_t)0; rnd_re < (mp_rnd_t)4; ++rnd_re) - for (rnd_im = (mp_rnd_t)0; rnd_im < (mp_rnd_t)4; ++rnd_im) - { - rnd = RNDC(rnd_re, rnd_im); - mpc_fr_div (q, MPC_RE (b), c, rnd); - mpc_div (q_ref, b, c, rnd); - if (mpc_cmp (q, q_ref)) - { - printf ("mpc_fr_div and mpc_div differ for " - "prec=%lu rnd=(%s,%s)\n", prec, - mpfr_print_rnd_mode (rnd_re), - mpfr_print_rnd_mode (rnd_im)); - OUT (b); - OUT (c); - OUT (q); - OUT (q_ref); - exit (1); - } - } - } + inexact = mpc_div (q, y, z, rnd); - mpc_clear (b); - mpc_clear (c); - mpc_clear (q); - mpc_clear (q_ref); + mpc_clear (y); + return inexact; } int @@ -81,7 +52,7 @@ main (void) { test_start(); - check_random (); + tgeneric (2, 1024, 7, 65535); test_end (); return 0; |