about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-06-02 11:53:21 +0000
committerUlrich Drepper <drepper@redhat.com>1999-06-02 11:53:21 +0000
commita384fa77082e93b172f129e249b7489ad0c493ad (patch)
treeec710c533f46652e0fcad4e5bb93ed5c705e3f64
parentb8cb072d1f364c36ec68b985b5cc174af471d86d (diff)
downloadglibc-a384fa77082e93b172f129e249b7489ad0c493ad.tar.gz
glibc-a384fa77082e93b172f129e249b7489ad0c493ad.tar.xz
glibc-a384fa77082e93b172f129e249b7489ad0c493ad.zip
Update.
1999-06-02  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/libm-ieee754/e_j0.c (__ieee754_y0): Fix array indices.
	Patch by mhagger@dera.gov.uk [PR libc/1145].

	* math/libm-test.c (y1_test): New tests.
	(y0_test): Likewise.
	(j1_test): Likewise.
	(j0_test): Likewise.
	(main): Added new tests.

1999-06-02  Jakub Jelinek  <jj@ultra.linux.cz>
-rw-r--r--ChangeLog13
-rw-r--r--math/libm-test.c125
-rw-r--r--sysdeps/libm-ieee754/e_j0.c6
3 files changed, 138 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index a0d3874014..c760df749d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
-1999-06-02  Jakub Jelinek   <jj@ultra.linux.cz>
+1999-06-02  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+	* sysdeps/libm-ieee754/e_j0.c (__ieee754_y0): Fix array indices.
+	Patch by mhagger@dera.gov.uk [PR libc/1145].
+
+	* math/libm-test.c (y1_test): New tests.
+	(y0_test): Likewise.
+	(j1_test): Likewise.
+	(j0_test): Likewise.
+	(main): Added new tests.
+
+1999-06-02  Jakub Jelinek  <jj@ultra.linux.cz>
 
 	* stdlib/longlong.h: Define UDIV_TIME on sparc64.
 	* sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c: New file.
diff --git a/math/libm-test.c b/math/libm-test.c
index 83975fc791..b5a9bc1408 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -45,11 +45,13 @@
    frexp, gamma, hypot,
    ilogb, isfinite, isinf, isnan, isnormal,
    isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
+   j0, j1,
    ldexp, lgamma, log, log10, log1p, log2, logb,
    modf, nearbyint, nextafter,
    pow, remainder, remquo, rint, lrint, llrint,
    round, lround, llround,
-   scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc
+   scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
+   y0, y1
 
    and for the following complex math functions:
    cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
@@ -57,7 +59,7 @@
 
    At the moment the following functions aren't tested:
    conj, cproj, cimag, creal, drem,
-   j0, j1, jn, y0, y1, yn,
+   jn, yn,
    significand,
    nan
 
@@ -5496,6 +5498,119 @@ fma_test (void)
 		   INVALID_EXCEPTION);
 }
 
+static void
+j0_test (void)
+{
+  errno = 0;
+  FUNC(j0) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  
+  /* j0 is the Bessel function of the first kind of order 0 */
+  check_isnan ("j0 (NaN) = NaN", FUNC(j0) (nan_value));
+
+  check ("j0 (-1.0) = 0.76519...", FUNC(j0) (-1.0), 0.76519768655796655145);
+  check ("j0 (0) = 1", FUNC(j0) (0.0), 1.0);
+  check ("j0 (0.1) = 0.99750...", FUNC(j0) (0.1), 0.99750156206604003228);
+  check ("j0 (0.7) = 0.88120...", FUNC(j0) (0.7), 0.88120088860740528084);
+  check ("j0 (1.0) = 0.76519...", FUNC(j0) (1.0), 0.76519768655796655145);
+  check ("j0 (1.5) = 0.51182...", FUNC(j0) (1.5), 0.51182767173591812875);
+  check_eps ("j0 (2.0) = 0.22389...", FUNC(j0) (2.0), 0.22389077914123566805,
+	     CHOOSE(0, 3e-17, 1.5e-8));
+  check_eps ("j0 (8.0) = 0.17165...", FUNC(j0) (8.0), 0.17165080713755390609,
+	     CHOOSE(0, 0, 1.5e-8));
+  check_eps ("j0 (10.0) = -0.24593...", FUNC(j0) (10.0), -0.24593576445134833520,
+	     CHOOSE(0, 6e-17, 1.5e-8));
+}
+
+static void
+j1_test (void)
+{
+  errno = 0;
+  FUNC(j1) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* j is the Bessel function of the first kind of order 1 */
+  check_isnan ("j1 (NaN) = NaN", FUNC(j0) (nan_value));
+
+  check ("j1 (-1.0) = -0.44005...", FUNC(j1) (-1.0), -0.44005058574493351596);
+  check ("j1 (0) = 0", FUNC(j1) (0.0), 0.0);
+  check ("j1 (0.1) = 0.049937...", FUNC(j1) (0.1), 0.049937526036241997556);
+  check ("j1 (0.7) = 0.32899...", FUNC(j1) (0.7), 0.32899574154005894785);
+  check ("j1 (1.0) = 0.44005...", FUNC(j1) (1.0), 0.44005058574493351596);
+  check ("j1 (1.5) = 0.55793...", FUNC(j1) (1.5), 0.55793650791009964199);
+  check_eps ("j1 (2.0) = 0.57672...", FUNC(j1) (2.0), 0.57672480775687338720,
+	     CHOOSE(0, 2e-16, 0));
+  check_eps ("j1 (8.0) = 0.23463...", FUNC(j1) (8.0), 0.23463634685391462438,
+	     CHOOSE(0, 0, 1.5e-8));
+  check_eps ("j1 (10.0) = 0.04347...", FUNC(j1) (10.0), 0.043472746168861436670,
+	     CHOOSE(0, 7e-18, 3.8e-9));
+}
+
+
+static void
+y0_test (void)
+{
+  errno = 0;
+  FUNC(y0) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* y0 is the Bessel function of the second kind of order 0 */
+  check_isinfn ("y0 (-1.0) = -inf", FUNC(y0) (-1.0));
+  check_isinfn ("y0 (0) = -inf", FUNC(y0) (0.0));
+  check_isnan ("y0 (NaN) = NaN", FUNC(y0) (nan_value));
+
+  check_eps ("y0 (0.1) = -1.53423...", FUNC(y0) (0.1), -1.5342386513503668441,
+	     CHOOSE(0, 3e-16, 1.2e-7));
+  check_eps ("y0 (0.7) = -0.19066...", FUNC(y0) (0.7), -0.19066492933739506743,
+	     CHOOSE(0, 6e-17, 1.5e-8));
+  check_eps ("y0 (1.0) = 0.08825...", FUNC(y0) (1.0), 0.088256964215676957983,
+	     CHOOSE(0, 2e-17, 7.5e-9));
+  check_eps ("y0 (1.5) = 0.38244...", FUNC(y0) (1.5), 0.38244892379775884396,
+	     CHOOSE(0, 6e-17, 3.0e-8));
+  check_eps ("y0 (2.0) = 0.51037...", FUNC(y0) (2.0), 0.51037567264974511960,
+	     CHOOSE(0, 2e-16 ,0));
+  check_eps ("y0 (8.0) = 0.22352...", FUNC(y0) (8.0), 0.22352148938756622053,
+	     CHOOSE(0, 3e-17, 1.5e-8));
+  check_eps ("y0 (10.0) = 0.05567...", FUNC(y0) (10.0), 0.055671167283599391424,
+	     CHOOSE(0, 0, 3.8e-9));
+}
+
+
+static void
+y1_test (void)
+{
+  errno = 0;
+  FUNC(y1) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* y1 is the Bessel function of the second kind of order 1 */
+  check_isinfn ("y1 (-1.0) = -inf", FUNC(y1) (-1.0));
+  check_isinfn ("y1 (0) = -inf", FUNC(y1) (0.0));
+  check_isnan ("y1 (NaN) = NaN", FUNC(y1) (nan_value));
+
+  check_eps ("y1 (0.1) = -6.45895...", FUNC(y1) (0.1), -6.4589510947020269877,
+	     CHOOSE(0, 9e-16, 4.8e-7));
+  check_eps ("y1 (0.7) = -1.10324...", FUNC(y1) (0.7), -1.1032498719076333697,
+	     CHOOSE(0, 3e-16, 0));
+  check_eps ("y1 (1.0) = -0.78121...", FUNC(y1) (1.0), -0.78121282130028871655,
+	     CHOOSE(0, 2e-16, 0));
+  check ("y1 (1.5) = -0.41230...", FUNC(y1) (1.5), -0.41230862697391129595);
+  check_eps ("y1 (2.0) = -0.10703...", FUNC(y1) (2.0), -0.10703243154093754689,
+	     CHOOSE(0, 2e-17, 1.5e-8));
+  check_eps ("y1 (8.0) = -0.15806...", FUNC(y1) (8.0), -0.15806046173124749426,
+	     CHOOSE(0, 0, 3.0e-8));
+  check_eps ("y1 (10.0) = 0.24901...", FUNC(y1) (10.0), 0.24901542420695388392,
+	     CHOOSE(0, 9e-17, 3.0e-8));
+}
+
 
 /* Tests for the comparison macros */
 typedef enum { is_less, is_equal, is_greater, is_unordered } comp_result;
@@ -5994,6 +6109,12 @@ main (int argc, char *argv[])
   /* multiply and add */
   fma_test ();
 
+  /* Bessel functions  */
+  j0_test ();
+  j1_test ();
+  y0_test ();
+  y1_test ();
+  
   /* special tests */
   identities ();
   inverse_functions ();
diff --git a/sysdeps/libm-ieee754/e_j0.c b/sysdeps/libm-ieee754/e_j0.c
index ff4c73bceb..55e8294bb9 100644
--- a/sysdeps/libm-ieee754/e_j0.c
+++ b/sysdeps/libm-ieee754/e_j0.c
@@ -234,9 +234,9 @@ V[]  =  {1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */
 	u2 = U[2]+z*U[3]; z4=z2*z2;
 	u3 = U[4]+z*U[5]; z6=z4*z2;
 	u = u1 + z2*u2 + z4*u3 + z6*U[6];
-	v1 = one+z*V[1];
-	v2 = V[2]+z*V[3];
-	v = v1 + z2*v2 + z4*V[4];
+	v1 = one+z*V[0];
+	v2 = V[1]+z*V[2];
+	v = v1 + z2*v2 + z4*V[3];
 #endif
 	return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
 }