summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-16 16:01:55 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-16 16:01:55 +0000
commit53e4fc7c14c9c4b9b3be6b941d853ac1fcc7f81a (patch)
tree6ca0f6baf11496ffc528a474687f4326c00e9796 /tests
parent3d3b3c4428015d063a0b8b5b1519588ab37920d1 (diff)
downloadmpfr-53e4fc7c14c9c4b9b3be6b941d853ac1fcc7f81a.tar.gz
replaced isnan() by Isnan()
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2180 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tabs.c3
-rw-r--r--tests/tadd.c48
-rw-r--r--tests/tadd_ui.c25
-rw-r--r--tests/tagm.c6
-rw-r--r--tests/tcmp.c31
-rw-r--r--tests/tcos.c2
-rw-r--r--tests/tdiv.c4
-rw-r--r--tests/tdiv_ui.c22
-rw-r--r--tests/tests.c4
-rw-r--r--tests/texp.c43
-rw-r--r--tests/tlog.c35
-rw-r--r--tests/tmul.c20
-rw-r--r--tests/tset_d.c15
-rw-r--r--tests/tset_ld.c2
-rw-r--r--tests/tsin.c2
-rw-r--r--tests/tsin_cos.c60
-rw-r--r--tests/tsqrt.c29
-rw-r--r--tests/tsqrt_ui.c26
-rw-r--r--tests/tsub_ui.c27
-rw-r--r--tests/ttan.c15
-rw-r--r--tests/tui_div.c26
-rw-r--r--tests/tui_sub.c27
22 files changed, 267 insertions, 205 deletions
diff --git a/tests/tabs.c b/tests/tabs.c
index a767cda1f..6ff7741c4 100644
--- a/tests/tabs.c
+++ b/tests/tabs.c
@@ -24,7 +24,6 @@ MA 02111-1307, USA. */
#include <float.h>
#include "gmp.h"
#include "mpfr.h"
-#include "mpfr-impl.h"
#include "mpfr-test.h"
void check_inexact _PROTO((void));
@@ -139,7 +138,7 @@ main (int argc, char *argv[])
mpfr_set_d (x, d, 0);
mpfr_abs (x, x, rnd);
dd = mpfr_get_d1 (x);
- if (!isnan(d) && (dd != absd))
+ if (!Isnan(d) && (dd != absd))
{
fprintf(stderr,
"Mismatch on d = %.20e\n", d);
diff --git a/tests/tadd.c b/tests/tadd.c
index 48008c840..a1b094726 100644
--- a/tests/tadd.c
+++ b/tests/tadd.c
@@ -71,32 +71,46 @@ _check (double x, double y, double z1, mp_rnd_t rnd_mode, unsigned int px,
cert = 1;
z2 = mpfr_get_d1 (zz);
mpfr_set_d (yy, z2, GMP_RNDN);
- if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(isnan(z1) && isnan(z2))) {
- printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
- printf("mpfr_add failed for x=%1.20e y=%1.20e with rnd_mode=%s\n",
- x, y, mpfr_print_rnd_mode(rnd_mode));
- exit(1);
- }
- mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz);
+ if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("expected sum is %1.20e, got %1.20e\n", z1, z2);
+ printf ("mpfr_add failed for x=%1.20e y=%1.20e with rnd_mode=%s\n",
+ x, y, mpfr_print_rnd_mode (rnd_mode));
+ exit (1);
+ }
+ mpfr_clear (xx);
+ mpfr_clear (yy);
+ mpfr_clear (zz);
}
void
checknan (double x, double y, mp_rnd_t rnd_mode, unsigned int px,
unsigned int py, unsigned int pz)
{
- double z2; mpfr_t xx, yy, zz;
+ double z2;
+ mpfr_t xx, yy, zz;
- mpfr_init2(xx, px);
- mpfr_init2(yy, py);
- mpfr_init2(zz, pz);
- mpfr_set_d(xx, x, rnd_mode);
- mpfr_set_d(yy, y, rnd_mode);
- mpfr_add(zz, xx, yy, rnd_mode);
- if (MPFR_IS_NAN(zz) == 0) { printf("Error, not an MPFR_NAN for xx = %1.20e, y = %1.20e\n", x, y); exit(1); }
+ mpfr_init2 (xx, px);
+ mpfr_init2 (yy, py);
+ mpfr_init2 (zz, pz);
+ mpfr_set_d (xx, x, rnd_mode);
+ mpfr_set_d (yy, y, rnd_mode);
+ mpfr_add (zz, xx, yy, rnd_mode);
+ if (MPFR_IS_NAN(zz) == 0)
+ {
+ printf ("Error, not an MPFR_NAN for xx = %1.20e, y = %1.20e\n", x, y);
+ exit (1);
+ }
z2 = mpfr_get_d1 (zz);
- if (!isnan(z2)) { printf("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e, got %1.20e\n", x, y, z2); exit(1); }
+ if (!Isnan(z2))
+ {
+ printf ("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e, got %1.20e\n", x, y, z2);
+ exit (1);
+ }
- mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz);
+ mpfr_clear (xx);
+ mpfr_clear (yy);
+ mpfr_clear (zz);
}
void
diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c
index f6563839d..cdf315463 100644
--- a/tests/tadd_ui.c
+++ b/tests/tadd_ui.c
@@ -42,20 +42,23 @@ void special _PROTO((void));
void
check3 (double x, unsigned long y, unsigned int rnd_mode, double z1)
{
- double z2; mpfr_t xx,zz;
+ double z2;
+ mpfr_t xx, zz;
- mpfr_init2(xx, 53);
- mpfr_init2(zz, 53);
- mpfr_set_d(xx, x, rnd_mode);
- mpfr_add_ui(zz, xx, y, rnd_mode);
+ mpfr_init2 (xx, 53);
+ mpfr_init2 (zz, 53);
+ mpfr_set_d (xx, x, rnd_mode);
+ mpfr_add_ui (zz, xx, y, rnd_mode);
z2 = mpfr_get_d1 (zz);
- if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
- printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
- printf("mpfr_add_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
- x, y, mpfr_print_rnd_mode(rnd_mode));
- exit(1);
+ if (z1 != z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("expected sum is %1.20e, got %1.20e\n",z1,z2);
+ printf ("mpfr_add_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
+ x, y, mpfr_print_rnd_mode(rnd_mode));
+ exit (1);
}
- mpfr_clear(xx); mpfr_clear(zz);
+ mpfr_clear (xx);
+ mpfr_clear (zz);
}
void
diff --git a/tests/tagm.c b/tests/tagm.c
index 7b4a3bd69..f02e5ea8d 100644
--- a/tests/tagm.c
+++ b/tests/tagm.c
@@ -53,8 +53,8 @@ dagm (double a, double b)
{
double u, v, tmpu, tmpv;
- if ((isnan(a))||(isnan(b)))
- return a+b;
+ if ((Isnan(a)) || (Isnan(b)))
+ return a + b;
tmpv=MAX(a,b);
tmpu=MIN(a,b);
@@ -91,7 +91,7 @@ check4 (double a, double b, mp_rnd_t rnd_mode, double res1)
res2 = mpfr_get_d1 (tres);
- if (res1!=res2 && (!isnan(res1) || !isnan(res2)))
+ if (res1!=res2 && !(Isnan(res1) && Isnan(res2)))
{
printf ("mpfr_agm failed for a=%1.20e, b=%1.20e, rnd_mode=%d\n",a,b,rnd_mode);
printf ("expected result is %1.20e, got %1.20e (%d ulp)\n",res1,res2,
diff --git a/tests/tcmp.c b/tests/tcmp.c
index e60fe18ad..e16b862ed 100644
--- a/tests/tcmp.c
+++ b/tests/tcmp.c
@@ -161,20 +161,27 @@ main (void)
exit (1);
}
- for (i=0;i<1000000;) { x=drand(); y=drand();
- if (!isnan(x) && !isnan(y)) {
- i++;
- mpfr_set_d(xx, x, 0);
- mpfr_set_d(yy, y, 0);
- c = mpfr_cmp(xx,yy);
- if ((c>0 && x<=y) || (c==0 && x!=y) || (c<0 && x>=y)) {
- printf("Error in mpfr_cmp with x=%1.20e, y=%1.20e mpfr_cmp(x,y)=%d\n",
- x,y,c); exit(1);
- }
+ for (i=0; i<1000000; )
+ {
+ x = drand();
+ y = drand();
+ if (!Isnan(x) && !Isnan(y))
+ {
+ i++;
+ mpfr_set_d (xx, x, 0);
+ mpfr_set_d (yy, y, 0);
+ c = mpfr_cmp (xx,yy);
+ if ((c>0 && x<=y) || (c==0 && x!=y) || (c<0 && x>=y))
+ {
+ printf ("Error in mpfr_cmp with x=%1.20e, y=%1.20e mpfr_cmp(x,y)=%d\n",
+ x, y, c);
+ exit (1);
+ }
+ }
}
- }
- mpfr_clear(xx); mpfr_clear(yy);
+ mpfr_clear (xx);
+ mpfr_clear (yy);
tests_end_mpfr ();
return 0;
diff --git a/tests/tcos.c b/tests/tcos.c
index aacfa0142..c0581e2eb 100644
--- a/tests/tcos.c
+++ b/tests/tcos.c
@@ -38,7 +38,7 @@ check53 (double x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_cos (c, xx, rnd_mode);
- if (mpfr_get_d1 (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c)))
+ if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c)))
{
fprintf (stderr, "mpfr_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
diff --git a/tests/tdiv.c b/tests/tdiv.c
index d0588dc6e..338bb061b 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -52,10 +52,10 @@ check4 (double N, double D, mp_rnd_t rnd_mode, int p, double Q)
mpfr_set_d(d, D, rnd_mode);
mpfr_div(q, n, d, rnd_mode);
Q2 = mpfr_get_d1 (q);
- if (p == 53 && Q != Q2 && (!isnan(Q) || !isnan(Q2)))
+ if (p == 53 && Q != Q2 && !(Isnan(Q) && Isnan(Q2)))
{
printf ("mpfr_div failed for n=%1.20e, d=%1.20e, rnd_mode=%s\n",
- N, D, mpfr_print_rnd_mode(rnd_mode));
+ N, D, mpfr_print_rnd_mode (rnd_mode));
printf ("correct quotient is %1.20e, mpfr_div gives %1.20e (%d ulp)\n",
Q, Q2, ulp (Q2, Q));
exit (1);
diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c
index 85d08e03f..7cebf8c94 100644
--- a/tests/tdiv_ui.c
+++ b/tests/tdiv_ui.c
@@ -37,17 +37,21 @@ check (double d, unsigned long u, mp_rnd_t rnd, double e)
mpfr_t x, y;
double f;
- mpfr_init2(x, 53); mpfr_init2(y, 53);
- mpfr_set_d(x, d, rnd);
- mpfr_div_ui(y, x, u, rnd);
+ mpfr_init2 (x, 53);
+ mpfr_init2 (y, 53);
+ mpfr_set_d (x, d, rnd);
+ mpfr_div_ui (y, x, u, rnd);
f = mpfr_get_d1 (y);
- if (f != e && (!isnan(f) || !isnan(e))) {
- printf("mpfr_div_ui failed for x=%1.20e, u=%lu, rnd=%s\n", d, u,
- mpfr_print_rnd_mode(rnd));
- printf("expected result is %1.20e, got %1.20e, dif=%d ulp\n",e,f,ulp(e,f));
- exit(1);
+ if (f != e && !(Isnan(f) && Isnan(e)))
+ {
+ printf ("mpfr_div_ui failed for x=%1.20e, u=%lu, rnd=%s\n", d, u,
+ mpfr_print_rnd_mode (rnd));
+ printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n",
+ e, f, ulp (e,f));
+ exit (1);
}
- mpfr_clear(x); mpfr_clear(y);
+ mpfr_clear (x);
+ mpfr_clear (y);
}
void
diff --git a/tests/tests.c b/tests/tests.c
index 345af3ff7..ef374c607 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -146,7 +146,7 @@ drand (void)
i[1] = LONG_RAND();
while (i[expo] >= 2146435072)
i[expo] = LONG_RAND(); /* avoids NaNs */
- if ((LONG_RAND() % 2) && !isnan (d))
+ if ((LONG_RAND() % 2) && !Isnan(d))
d = -d; /* generates negative numbers */
return d;
}
@@ -201,10 +201,8 @@ dbl (double m, int e)
return m;
}
-#ifndef HAVE_ISNAN
int
Isnan (double d)
{
return (d) != (d);
}
-#endif
diff --git a/tests/texp.c b/tests/texp.c
index 4bad0bac0..da2cf1ab9 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -43,26 +43,35 @@ int maxu=0;
int
check3 (double d, mp_rnd_t rnd, double e)
{
- mpfr_t x, y; double f; int u=0;
+ mpfr_t x, y;
+ double f;
+ int u = 0;
- mpfr_init2(x, 53); mpfr_init2(y, 53);
- mpfr_set_d(x, d, rnd);
- mpfr_exp(y, x, rnd);
+ mpfr_init2 (x, 53);
+ mpfr_init2 (y, 53);
+ mpfr_set_d (x, d, rnd);
+ mpfr_exp (y, x, rnd);
f = mpfr_get_d1 (y);
- if (f != e && (!isnan(f) || !isnan(e))) {
- u = ulp(e, f);
- if (u<0) {
- if (u == (mp_limb_t) 1 << (mp_bits_per_limb-1)) u += 1;
- u=-u;
- }
- if (u!=0) {
- printf ("mpfr_exp failed for x=%1.20e, rnd=%s\n", d,
- mpfr_print_rnd_mode(rnd));
- printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n",e,f,u);
- exit (1);
+ if (f != e && !(Isnan(f) && Isnan(e)))
+ {
+ u = ulp (e, f);
+ if (u < 0)
+ {
+ if (u == (mp_limb_t) 1 << (mp_bits_per_limb-1))
+ u += 1;
+ u = -u;
+ }
+ if (u != 0)
+ {
+ printf ("mpfr_exp failed for x=%1.20e, rnd=%s\n", d,
+ mpfr_print_rnd_mode (rnd));
+ printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n",
+ e, f, u);
+ exit (1);
+ }
}
- }
- mpfr_clear(x); mpfr_clear(y);
+ mpfr_clear (x);
+ mpfr_clear (y);
return u;
}
diff --git a/tests/tlog.c b/tests/tlog.c
index 168d6d802..af388488e 100644
--- a/tests/tlog.c
+++ b/tests/tlog.c
@@ -64,24 +64,27 @@ check1 (double a, mp_rnd_t rnd_mode, double res1, int ck, int max_ulp)
{
mpfr_t ta, tres;
double res2;
- int diff=0;
+ int diff = 0;
/* ck=1 iff res1 is certified correct */
- mpfr_init2(ta, 53);
- mpfr_init2(tres, 53);
- mpfr_set_d(ta, a, GMP_RNDN);
- mpfr_log(tres, ta, rnd_mode);
- res2=mpfr_get_d1 (tres);
- mpfr_clear(ta); mpfr_clear(tres);
-
- if (res1!=res2 && (!isnan(res1) || !isnan(res2))) {
- diff = ulp(res1,res2);
- printf("mpfr_log failed for a=%1.20e, rnd_mode=%s\n", a,
- mpfr_print_rnd_mode(rnd_mode));
- printf("correct result is %1.20e\n mpfr_log gives %1.20e (%d ulp)\n",res1,res2,ulp(res1,res2));
- exit(1);
- }
- if (!isnan(res1) || !isnan(res2))
+ mpfr_init2 (ta, 53);
+ mpfr_init2 (tres, 53);
+ mpfr_set_d (ta, a, GMP_RNDN);
+ mpfr_log (tres, ta, rnd_mode);
+ res2 = mpfr_get_d1 (tres);
+ mpfr_clear (ta);
+ mpfr_clear (tres);
+
+ if (res1 != res2 && !(Isnan(res1) && Isnan(res2)))
+ {
+ diff = ulp (res1,res2);
+ printf ("mpfr_log failed for a=%1.20e, rnd_mode=%s\n", a,
+ mpfr_print_rnd_mode (rnd_mode));
+ printf ("correct result is %1.20e\n mpfr_log gives %1.20e (%d ulp)\n",
+ res1, res2, ulp (res1,res2));
+ exit (1);
+ }
+ if (!Isnan(res1) || !Isnan(res2))
return diff;
else
return 0;
diff --git a/tests/tmul.c b/tests/tmul.c
index c2d348747..533ceef5e 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -68,7 +68,8 @@ _check (double x, double y, double res, mp_rnd_t rnd_mode, unsigned int px,
void
check53 (double x, double y, mp_rnd_t rnd_mode, double z1)
{
- double z2; mpfr_t xx, yy, zz;
+ double z2;
+ mpfr_t xx, yy, zz;
mpfr_init2 (xx, 53);
mpfr_init2 (yy, 53);
@@ -77,13 +78,16 @@ check53 (double x, double y, mp_rnd_t rnd_mode, double z1)
mpfr_set_d (yy, y, rnd_mode);
mpfr_mul (zz, xx, yy, rnd_mode);
z2 = mpfr_get_d1 (zz);
- if (z1!=z2 && (!isnan(z1) || !isnan(z2))) {
- printf("mpfr_mul failed for x=%1.20e y=%1.20e with rnd_mode=%s\n",
- x, y, mpfr_print_rnd_mode(rnd_mode));
- printf("correct result is %1.20e, mpfr_mul gives %1.20e\n", z1, z2);
- exit(1);
- }
- mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz);
+ if (z1 != z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("mpfr_mul failed for x=%1.20e y=%1.20e with rnd_mode=%s\n",
+ x, y, mpfr_print_rnd_mode(rnd_mode));
+ printf ("correct result is %1.20e, mpfr_mul gives %1.20e\n", z1, z2);
+ exit (1);
+ }
+ mpfr_clear (xx);
+ mpfr_clear (yy);
+ mpfr_clear (zz);
}
/* checks that x*y gives the same results in double
diff --git a/tests/tset_d.c b/tests/tset_d.c
index 5fab50807..5a30148a4 100644
--- a/tests/tset_d.c
+++ b/tests/tset_d.c
@@ -118,16 +118,19 @@ main (int argc, char *argv[])
#endif
mpfr_set_d (x, d, 0);
dd = mpfr_get_d1 (x);
- if (d != dd && (!isnan(d) || !isnan(dd)))
+ if (d != dd && !(Isnan(d) && Isnan(dd)))
{
- fprintf(stderr,
- "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x));
- mpfr_print_binary(x); putchar('\n');
- exit(1);
+ fprintf (stderr,
+ "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x));
+ mpfr_print_binary (x);
+ putchar ('\n');
+ exit (1);
}
}
- mpfr_clear(x); mpfr_clear(y); mpfr_clear(z);
+ mpfr_clear (x);
+ mpfr_clear (y);
+ mpfr_clear (z);
tests_end_mpfr ();
return 0;
diff --git a/tests/tset_ld.c b/tests/tset_ld.c
index 2ec220936..c1b974c0f 100644
--- a/tests/tset_ld.c
+++ b/tests/tset_ld.c
@@ -47,7 +47,7 @@ check_set_get (long double d, mpfr_t x)
exit (1);
}
e = mpfr_get_ld (x, r);
- if (e != d && !(isnan(e) && isnan(d)))
+ if (e != d && !(LONGDOUBLE_ISNAN(e) && LONGDOUBLE_ISNAN(d)))
{
fprintf (stderr, "Error: mpfr_get_ld o mpfr_set_ld <> Id\n");
fprintf (stderr, "d=%1.30Le get_ld(set_ld(d))=%1.30Le\n", d, e);
diff --git a/tests/tsin.c b/tests/tsin.c
index 5e04aee8a..68ccd006d 100644
--- a/tests/tsin.c
+++ b/tests/tsin.c
@@ -36,7 +36,7 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin (s, xx, rnd_mode);
- if (mpfr_get_d1 (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s)))
+ if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s)))
{
fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c
index ef934b6ba..0a2559e5e 100644
--- a/tests/tsin_cos.c
+++ b/tests/tsin_cos.c
@@ -56,20 +56,22 @@ void check53 (double x, double sin_x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (s, c, xx, rnd_mode);
- if (mpfr_get_d1 (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s))) {
- fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d1 (s), sin_x);
- exit(1);
- }
- if (mpfr_get_d1 (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c))) {
- fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d1 (c), cos_x);
- exit(1);
- }
+ if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s)))
+ {
+ fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (s), sin_x);
+ exit (1);
+ }
+ if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c)))
+ {
+ fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (c), cos_x);
+ exit (1);
+ }
mpfr_clear (xx);
mpfr_clear (s);
mpfr_clear (c);
@@ -83,13 +85,14 @@ void check53sin (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (s, NULL, xx, rnd_mode);
- if (mpfr_get_d1 (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s))) {
- fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d1 (s), sin_x);
- exit(1);
- }
+ if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s)))
+ {
+ fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (s), sin_x);
+ exit (1);
+ }
mpfr_clear (xx);
mpfr_clear (s);
}
@@ -102,13 +105,14 @@ void check53cos (double x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (NULL, c, xx, rnd_mode);
- if (mpfr_get_d1 (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c))) {
- fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d1 (c), cos_x);
- exit(1);
- }
+ if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c)))
+ {
+ fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (c), cos_x);
+ exit (1);
+ }
mpfr_clear (xx);
mpfr_clear (c);
}
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index ada9f2b33..32850baf9 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -44,21 +44,24 @@ void check_nan _PROTO((void));
void
check3 (double a, mp_rnd_t rnd_mode, double Q)
{
- mpfr_t q; double Q2; int u;
+ mpfr_t q;
+ double Q2;
+ int u;
- mpfr_init2(q, 53);
- mpfr_set_d(q, a, rnd_mode);
- mpfr_sqrt(q, q, rnd_mode);
+ mpfr_init2 (q, 53);
+ mpfr_set_d (q, a, rnd_mode);
+ mpfr_sqrt (q, q, rnd_mode);
Q2 = mpfr_get_d1 (q);
- if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) {
- u = ulp(Q2,Q);
- printf("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n",
- a, mpfr_print_rnd_mode(rnd_mode));
- printf("expected sqrt is %1.20e, got %1.20e (%d ulp)\n",Q,Q2,u);
- mpfr_clear(q);
- exit(1);
- }
- mpfr_clear(q);
+ if (Q!=Q2 && !(Isnan(Q) && Isnan(Q2)))
+ {
+ u = ulp (Q2,Q);
+ printf ("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n",
+ a, mpfr_print_rnd_mode (rnd_mode));
+ printf ("expected sqrt is %1.20e, got %1.20e (%d ulp)\n",Q,Q2,u);
+ mpfr_clear (q);
+ exit (1);
+ }
+ mpfr_clear (q);
}
void
diff --git a/tests/tsqrt_ui.c b/tests/tsqrt_ui.c
index 64f2239c9..1ccef56e9 100644
--- a/tests/tsqrt_ui.c
+++ b/tests/tsqrt_ui.c
@@ -34,19 +34,23 @@ int maxulp=0;
void
check (unsigned long a, mp_rnd_t rnd_mode, double Q)
{
- mpfr_t q; double Q2; int u;
+ mpfr_t q;
+ double Q2;
+ int u;
- mpfr_init2(q, 53);
- mpfr_sqrt_ui(q, a, rnd_mode);
+ mpfr_init2 (q, 53);
+ mpfr_sqrt_ui (q, a, rnd_mode);
Q2 = mpfr_get_d1 (q);
- if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) {
- u = ulp(Q2,Q);
- printf("mpfr_sqrt_ui failed for a=%lu, rnd_mode=%s\n",
- a, mpfr_print_rnd_mode(rnd_mode));
- printf("sqrt gives %1.20e, mpfr_sqrt_ui gives %1.20e (%d ulp)\n",Q,Q2,u);
- exit(1);
- }
- mpfr_clear(q);
+ if (Q != Q2 && !(Isnan(Q) && Isnan(Q2)))
+ {
+ u = ulp (Q2,Q);
+ printf ("mpfr_sqrt_ui failed for a=%lu, rnd_mode=%s\n",
+ a, mpfr_print_rnd_mode (rnd_mode));
+ printf ("sqrt gives %1.20e, mpfr_sqrt_ui gives %1.20e (%d ulp)\n",
+ Q, Q2, u);
+ exit (1);
+ }
+ mpfr_clear (q);
}
double five = 5.0;
diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c
index 5dd992d80..b5f2d0034 100644
--- a/tests/tsub_ui.c
+++ b/tests/tsub_ui.c
@@ -42,21 +42,22 @@ check3 (double x, unsigned long y, mp_rnd_t rnd_mode, double z1)
double z2;
mpfr_t xx,zz;
- mpfr_init(xx);
- mpfr_init(zz);
- mpfr_set_prec(xx, 53);
- mpfr_set_prec(zz, 53);
- mpfr_set_d(xx, x, rnd_mode);
- mpfr_sub_ui(zz, xx, y, rnd_mode);
+ mpfr_init (xx);
+ mpfr_init (zz);
+ mpfr_set_prec (xx, 53);
+ mpfr_set_prec (zz, 53);
+ mpfr_set_d (xx, x, rnd_mode);
+ mpfr_sub_ui (zz, xx, y, rnd_mode);
z2 = mpfr_get_d1 (zz);
- if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
- printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
- printf("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
- x, y, mpfr_print_rnd_mode(rnd_mode));
- exit(1);
+ if (z1!=z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("expected sum is %1.20e, got %1.20e\n",z1,z2);
+ printf ("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
+ x, y, mpfr_print_rnd_mode (rnd_mode));
+ exit (1);
}
- mpfr_clear(xx);
- mpfr_clear(zz);
+ mpfr_clear (xx);
+ mpfr_clear (zz);
}
/* FastTwoSum: if EXP(x) >= EXP(y), u = o(x+y), v = o(u-x), w = o(y-v),
diff --git a/tests/ttan.c b/tests/ttan.c
index f0efd5eb9..54c999b13 100644
--- a/tests/ttan.c
+++ b/tests/ttan.c
@@ -38,13 +38,14 @@ check53 (double x, double tan_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_tan (s, xx, rnd_mode);
- if (mpfr_get_d1 (s) != tan_x && (!isnan(tan_x) || !mpfr_nan_p(s))) {
- fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d1 (s), tan_x);
- exit(1);
- }
+ if (mpfr_get_d1 (s) != tan_x && !(Isnan(tan_x) && mpfr_nan_p(s)))
+ {
+ fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (s), tan_x);
+ exit (1);
+ }
mpfr_clear (xx);
mpfr_clear (s);
}
diff --git a/tests/tui_div.c b/tests/tui_div.c
index 9c7fd6c51..fedd92ee3 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -38,21 +38,23 @@ void check_nan _PROTO((void));
void
check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1)
{
- double z2; mpfr_t xx, zz;
+ double z2;
+ mpfr_t xx, zz;
- mpfr_init2(xx, 53);
- mpfr_init2(zz, 53);
- mpfr_set_d(xx, x, rnd_mode);
- mpfr_ui_div(zz, y, xx, rnd_mode);
+ mpfr_init2 (xx, 53);
+ mpfr_init2 (zz, 53);
+ mpfr_set_d (xx, x, rnd_mode);
+ mpfr_ui_div (zz, y, xx, rnd_mode);
z2 = mpfr_get_d1 (zz);
- if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
- printf("expected quotient is %1.20e, got %1.20e\n",z1,z2);
- printf("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n",
- y, x, mpfr_print_rnd_mode(rnd_mode));
- exit(1);
+ if (z1 != z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("expected quotient is %1.20e, got %1.20e\n", z1, z2);
+ printf ("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n",
+ y, x, mpfr_print_rnd_mode (rnd_mode));
+ exit (1);
}
- mpfr_clear(xx);
- mpfr_clear(zz);
+ mpfr_clear (xx);
+ mpfr_clear (zz);
}
void
diff --git a/tests/tui_sub.c b/tests/tui_sub.c
index 1a2c67421..45ec763d9 100644
--- a/tests/tui_sub.c
+++ b/tests/tui_sub.c
@@ -135,20 +135,23 @@ special (void)
void
check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1)
{
- double z2; mpfr_t xx, zz;
+ double z2;
+ mpfr_t xx, zz;
- mpfr_init2(xx, 53);
- mpfr_init2(zz, 53);
- mpfr_set_d(xx, x, rnd_mode);
- mpfr_ui_sub(zz, y, xx, rnd_mode);
+ mpfr_init2 (xx, 53);
+ mpfr_init2 (zz, 53);
+ mpfr_set_d (xx, x, rnd_mode);
+ mpfr_ui_sub (zz, y, xx, rnd_mode);
z2 = mpfr_get_d1 (zz);
- if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
- printf("expected difference is %1.20e, got %1.20e\n",z1,z2);
- printf("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n",
- y, x, mpfr_print_rnd_mode(rnd_mode));
- exit(1);
- }
- mpfr_clear(xx); mpfr_clear(zz);
+ if (z1 != z2 && !(Isnan(z1) && Isnan(z2)))
+ {
+ printf ("expected difference is %1.20e, got %1.20e\n",z1,z2);
+ printf ("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n",
+ y, x, mpfr_print_rnd_mode (rnd_mode));
+ exit (1);
+ }
+ mpfr_clear (xx);
+ mpfr_clear (zz);
}
/* if u = o(x-y), v = o(u-x), w = o(v+y), then x-y = u-w */