summaryrefslogtreecommitdiff
path: root/tests/tdiv.c
diff options
context:
space:
mode:
authorthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-09-23 10:25:36 +0000
committerthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-09-23 10:25:36 +0000
commit9dd7c83ed9f5a47c097463399fbef3da2caf5898 (patch)
treedee411695c778f669a535587ca2461274e8c2d20 /tests/tdiv.c
parent5fcf9d411de8f98178941fb5a8e3b54a8a39d0d4 (diff)
downloadmpc-9dd7c83ed9f5a47c097463399fbef3da2caf5898.tar.gz
tests/tdiv.c: complete tests with regular value and move them in a separated function.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@185 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tdiv.c')
-rw-r--r--tests/tdiv.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/tests/tdiv.c b/tests/tdiv.c
index efe7acf..cda51f9 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -230,48 +230,79 @@ mpc_div_ref (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd)
return MPC_INEX(inex_re, inex_im);
}
-int
-main (void)
+static void
+check_regular (void)
{
- mpc_t b, c, q, q_ref;
- int inex, i;
- mp_prec_t prec;
- mp_rnd_t rnd_re, rnd_im;
- mpc_rnd_t rnd;
+ mpc_t b, c, q;
+ int inex;
mpc_init (b);
mpc_init (c);
mpc_init (q);
- mpc_init (q_ref);
mpc_set_prec (b, 10);
mpc_set_prec (c, 10);
mpc_set_prec (q, 10);
+ /* inexact result */
mpc_set_ui_ui (b, 973, 964, MPC_RNDNN);
mpc_set_ui_ui (c, 725, 745, MPC_RNDNN);
-
inex = mpc_div (q, b, c, MPC_RNDZZ);
mpc_set_si_si (b, 43136, -787, MPC_RNDNN);
mpc_div_2exp (b, b, 15, MPC_RNDNN);
- if (mpc_cmp (q, b))
+ if (mpc_cmp (q, b) || MPC_INEX_RE (inex) == 0 || MPC_INEX_IM (inex) == 0)
{
- fprintf (stderr, "mpc_div failed for (973+I*964)/(725+I*745)\n");
+ printf ("mpc_div failed for (973+I*964)/(725+I*745)\n");
exit (1);
}
+ /* exact result */
mpc_set_si_si (b, -837, 637, MPC_RNDNN);
mpc_set_si_si (c, 63, -5, MPC_RNDNN);
inex = mpc_div (q, b, c, MPC_RNDZN);
+ mpc_set_si_si (b, -14, 9, MPC_RNDNN);
+ if (mpc_cmp (q, b) || inex != 0)
+ {
+ printf ("mpc_div failed for (-837+I*637)/(63-I*5)\n");
+ exit (1);
+ }
mpc_set_prec (b, 2);
mpc_set_prec (c, 2);
mpc_set_prec (q, 2);
+ /* exact result */
mpc_set_ui_ui (b, 4, 3, MPC_RNDNN);
mpc_set_ui_ui (c, 1, 2, MPC_RNDNN);
-
inex = mpc_div (q, b, c, MPC_RNDNN);
+ mpc_set_si_si (b, 2, -1, MPC_RNDNN);
+ if (mpc_cmp (q, b) || inex != 0)
+ {
+ printf ("mpc_div failed for (4+I*3)/(1+I*2)\n");
+ exit (1);
+ }
+
+ mpc_clear (b);
+ mpc_clear (c);
+ mpc_clear (q);
+}
+
+
+int
+main (void)
+{
+ mpc_t b, c, q, q_ref;
+ int inex, i;
+ mp_prec_t prec;
+ mp_rnd_t rnd_re, rnd_im;
+ mpc_rnd_t rnd;
+
+ check_regular ();
+
+ mpc_init (b);
+ mpc_init (c);
+ mpc_init (q);
+ mpc_init (q_ref);
for (prec = 2; prec < 1000; prec++)
{