summaryrefslogtreecommitdiff
path: root/libc/sysdeps/ieee754/ldbl-96/e_j1l.c
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-10-25 00:37:10 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-10-25 00:37:10 +0000
commit4bbe4e2185c5484328182720ff7b3bb4f9593bff (patch)
treecd67e40a74928c0f58d4f5b79d2e260e4099fee7 /libc/sysdeps/ieee754/ldbl-96/e_j1l.c
parent91b4be71461f78cabe1fb5f164cea71b60e9e98a (diff)
downloadeglibc2-4bbe4e2185c5484328182720ff7b3bb4f9593bff.tar.gz
Merge changes between r15223 and r15532 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@15545 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/ieee754/ldbl-96/e_j1l.c')
-rw-r--r--libc/sysdeps/ieee754/ldbl-96/e_j1l.c156
1 files changed, 21 insertions, 135 deletions
diff --git a/libc/sysdeps/ieee754/ldbl-96/e_j1l.c b/libc/sysdeps/ieee754/ldbl-96/e_j1l.c
index 62a8ce0cb..369fd830f 100644
--- a/libc/sysdeps/ieee754/ldbl-96/e_j1l.c
+++ b/libc/sysdeps/ieee754/ldbl-96/e_j1l.c
@@ -11,9 +11,9 @@
/* Long double expansions are
Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov>
- and are incorporated herein by permission of the author. The author
+ and are incorporated herein by permission of the author. The author
reserves the right to distribute this material elsewhere under different
- copying permissions. These modifications are distributed here under
+ copying permissions. These modifications are distributed here under
the following terms:
This library is free software; you can redistribute it and/or
@@ -38,17 +38,17 @@
* for x in (0,2)
* j1(x) = x/2 + x*z*R0/S0, where z = x*x;
* for x in (2,inf)
- * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
- * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
* as follow:
* cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
* = 1/sqrt(2) * (sin(x) - cos(x))
* sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
* = -1/sqrt(2) * (sin(x) + cos(x))
- * (To avoid cancellation, use
+ * (To avoid cancellation, use
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- * to compute the worse one.)
+ * to compute the worse one.)
*
* 3 Special cases
* j1(nan)= nan
@@ -66,25 +66,17 @@
* Note: For tiny x, 1/x dominate y1 and hence
* y1(tiny) = -2/pi/tiny
* 3. For x>=2.
- * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
* by method mentioned above.
*/
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static long double pone (long double), qone (long double);
-#else
-static long double pone (), qone ();
-#endif
-#ifdef __STDC__
static const long double
-#else
-static long double
-#endif
huge = 1e4930L,
one = 1.0L,
invsqrtpi = 5.6418958354775628694807945156077258584405e-1L,
@@ -110,21 +102,11 @@ R[5] = {
/* 1.000000000000000000000000000000000000000E0L, */
};
-#ifdef __STDC__
static const long double zero = 0.0;
-#else
-static long double zero = 0.0;
-#endif
-#ifdef __STDC__
long double
__ieee754_j1l (long double x)
-#else
-long double
-__ieee754_j1l (x)
- long double x;
-#endif
{
long double z, c, r, s, ss, cc, u, v, y;
int32_t ix;
@@ -132,7 +114,7 @@ __ieee754_j1l (x)
GET_LDOUBLE_WORDS (se, i0, i1, x);
ix = se & 0x7fff;
- if (ix >= 0x7fff)
+ if (__builtin_expect (ix >= 0x7fff, 0))
return one / x;
y = fabsl (x);
if (ix >= 0x4000)
@@ -152,7 +134,7 @@ __ieee754_j1l (x)
* j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
* y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
*/
- if (ix > 0x4080)
+ if (__builtin_expect (ix > 0x4080, 0))
z = (invsqrtpi * cc) / __ieee754_sqrtl (y);
else
{
@@ -165,7 +147,7 @@ __ieee754_j1l (x)
else
return z;
}
- if (ix < 0x3fde) /* |x| < 2^-33 */
+ if (__builtin_expect (ix < 0x3fde, 0)) /* |x| < 2^-33 */
{
if (huge + x > one)
return 0.5 * x; /* inexact if x!=0 necessary */
@@ -176,16 +158,13 @@ __ieee754_j1l (x)
r *= x;
return (x * 0.5 + r / s);
}
+strong_alias (__ieee754_j1l, __j1l_finite)
/* Y1(x) = 2/pi * (log(x) * j1(x) - 1/x) + x R(x^2)
0 <= x <= 2
Peak relative error 2.3e-23 */
-#ifdef __STDC__
static const long double U0[6] = {
-#else
-static long double U0[6] = {
-#endif
-5.908077186259914699178903164682444848615E10L,
1.546219327181478013495975514375773435962E10L,
-6.438303331169223128870035584107053228235E8L,
@@ -193,11 +172,7 @@ static long double U0[6] = {
-6.138043997084355564619377183564196265471E4L,
1.418503228220927321096904291501161800215E2L,
};
-#ifdef __STDC__
static const long double V0[5] = {
-#else
-static long double V0[5] = {
-#endif
3.013447341682896694781964795373783679861E11L,
4.669546565705981649470005402243136124523E9L,
3.595056091631351184676890179233695857260E7L,
@@ -207,14 +182,8 @@ static long double V0[5] = {
};
-#ifdef __STDC__
long double
__ieee754_y1l (long double x)
-#else
-long double
-__ieee754_y1l (x)
- long double x;
-#endif
{
long double z, s, c, ss, cc, u, v;
int32_t ix;
@@ -223,11 +192,11 @@ __ieee754_y1l (x)
GET_LDOUBLE_WORDS (se, i0, i1, x);
ix = se & 0x7fff;
/* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
- if (se & 0x8000)
+ if (__builtin_expect (se & 0x8000, 0))
return zero / (zero * x);
- if (ix >= 0x7fff)
+ if (__builtin_expect (ix >= 0x7fff, 0))
return one / (x + x * x);
- if ((i0 | i1) == 0)
+ if (__builtin_expect ((i0 | i1) == 0, 0))
return -HUGE_VALL + x; /* -inf and overflow exception. */
if (ix >= 0x4000)
{ /* |x| >= 2.0 */
@@ -253,7 +222,7 @@ __ieee754_y1l (x)
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
* to compute the worse one.
*/
- if (ix > 0x4080)
+ if (__builtin_expect (ix > 0x4080, 0))
z = (invsqrtpi * ss) / __ieee754_sqrtl (x);
else
{
@@ -263,7 +232,7 @@ __ieee754_y1l (x)
}
return z;
}
- if (ix <= 0x3fbe)
+ if (__builtin_expect (ix <= 0x3fbe, 0))
{ /* x < 2**-65 */
return (-tpi / x);
}
@@ -273,12 +242,13 @@ __ieee754_y1l (x)
return (x * (u / v) +
tpi * (__ieee754_j1l (x) * __ieee754_logl (x) - one / x));
}
+strong_alias (__ieee754_y1l, __y1l_finite)
/* For x >= 8, the asymptotic expansions of pone is
* 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
* We approximate pone by
- * pone(x) = 1 + (R/S)
+ * pone(x) = 1 + (R/S)
*/
/* J1(x) cosX + Y1(x) sinX = sqrt( 2/(pi x)) P1(x)
@@ -286,11 +256,7 @@ __ieee754_y1l (x)
8 <= x <= inf (0 <= z <= 0.125)
Peak relative error 5.2e-22 */
-#ifdef __STDC__
static const long double pr8[7] = {
-#else
-static long double pr8[7] = {
-#endif
8.402048819032978959298664869941375143163E-9L,
1.813743245316438056192649247507255996036E-6L,
1.260704554112906152344932388588243836276E-4L,
@@ -299,11 +265,7 @@ static long double pr8[7] = {
1.131111483254318243139953003461511308672E-1L,
4.480715825681029711521286449131671880953E-2L,
};
-#ifdef __STDC__
static const long double ps8[6] = {
-#else
-static long double ps8[6] = {
-#endif
7.169748325574809484893888315707824924354E-8L,
1.556549720596672576431813934184403614817E-5L,
1.094540125521337139209062035774174565882E-3L,
@@ -317,11 +279,7 @@ static long double ps8[6] = {
P1(x) = 1 + z^2 R(z^2), z=1/x
4.54541015625 <= x <= 8
Peak relative error 7.7e-22 */
-#ifdef __STDC__
static const long double pr5[7] = {
-#else
-static long double pr5[7] = {
-#endif
4.318486887948814529950980396300969247900E-7L,
4.715341880798817230333360497524173929315E-5L,
1.642719430496086618401091544113220340094E-3L,
@@ -330,11 +288,7 @@ static long double pr5[7] = {
1.755576530055079253910829652698703791957E-1L,
3.218803858282095929559165965353784980613E-2L,
};
-#ifdef __STDC__
static const long double ps5[6] = {
-#else
-static long double ps5[6] = {
-#endif
3.685108812227721334719884358034713967557E-6L,
4.069102509511177498808856515005792027639E-4L,
1.449728676496155025507893322405597039816E-2L,
@@ -348,11 +302,7 @@ static long double ps5[6] = {
P1(x) = 1 + z^2 R(z^2), z=1/x
2.85711669921875 <= x <= 4.54541015625
Peak relative error 6.5e-21 */
-#ifdef __STDC__
static const long double pr3[7] = {
-#else
-static long double pr3[7] = {
-#endif
1.265251153957366716825382654273326407972E-5L,
8.031057269201324914127680782288352574567E-4L,
1.581648121115028333661412169396282881035E-2L,
@@ -361,11 +311,7 @@ static long double pr3[7] = {
2.559223765418386621748404398017602935764E-1L,
2.277136933287817911091370397134882441046E-2L,
};
-#ifdef __STDC__
static const long double ps3[6] = {
-#else
-static long double ps3[6] = {
-#endif
1.079681071833391818661952793568345057548E-4L,
6.986017817100477138417481463810841529026E-3L,
1.429403701146942509913198539100230540503E-1L,
@@ -379,11 +325,7 @@ static long double ps3[6] = {
P1(x) = 1 + z^2 R(z^2), z=1/x
2 <= x <= 2.85711669921875
Peak relative error 3.5e-21 */
-#ifdef __STDC__
static const long double pr2[7] = {
-#else
-static long double pr2[7] = {
-#endif
2.795623248568412225239401141338714516445E-4L,
1.092578168441856711925254839815430061135E-2L,
1.278024620468953761154963591853679640560E-1L,
@@ -392,11 +334,7 @@ static long double pr2[7] = {
3.544176317308370086415403567097130611468E-1L,
1.604142674802373041247957048801599740644E-2L,
};
-#ifdef __STDC__
static const long double ps2[6] = {
-#else
-static long double ps2[6] = {
-#endif
2.385605161555183386205027000675875235980E-3L,
9.616778294482695283928617708206967248579E-2L,
1.195215570959693572089824415393951258510E0L,
@@ -407,20 +345,10 @@ static long double ps2[6] = {
};
-#ifdef __STDC__
static long double
pone (long double x)
-#else
-static long double
-pone (x)
- long double x;
-#endif
{
-#ifdef __STDC__
const long double *p, *q;
-#else
- long double *p, *q;
-#endif
long double z, r, s;
int32_t ix;
u_int32_t se, i0, i1;
@@ -462,7 +390,7 @@ pone (x)
/* For x >= 8, the asymptotic expansions of qone is
* 3/8 s - 105/1024 s^3 - ..., where s = 1/x.
* We approximate pone by
- * qone(x) = s*(0.375 + (R/S))
+ * qone(x) = s*(0.375 + (R/S))
*/
/* Y1(x)cosX - J1(x)sinX = sqrt( 2/(pi x)) Q1(x),
@@ -470,11 +398,7 @@ pone (x)
8 <= x <= inf
Peak relative error 8.3e-22 */
-#ifdef __STDC__
static const long double qr8[7] = {
-#else
-static long double qr8[7] = {
-#endif
-5.691925079044209246015366919809404457380E-10L,
-1.632587664706999307871963065396218379137E-7L,
-1.577424682764651970003637263552027114600E-5L,
@@ -483,11 +407,7 @@ static long double qr8[7] = {
-6.854943629378084419631926076882330494217E-2L,
-1.055448290469180032312893377152490183203E-1L,
};
-#ifdef __STDC__
static const long double qs8[7] = {
-#else
-static long double qs8[7] = {
-#endif
5.550982172325019811119223916998393907513E-9L,
1.607188366646736068460131091130644192244E-6L,
1.580792530091386496626494138334505893599E-4L,
@@ -502,11 +422,7 @@ static long double qs8[7] = {
Q1(x) = z(.375 + z^2 R(z^2)), z=1/x
4.54541015625 <= x <= 8
Peak relative error 4.1e-22 */
-#ifdef __STDC__
static const long double qr5[7] = {
-#else
-static long double qr5[7] = {
-#endif
-6.719134139179190546324213696633564965983E-8L,
-9.467871458774950479909851595678622044140E-6L,
-4.429341875348286176950914275723051452838E-4L,
@@ -515,11 +431,7 @@ static long double qr5[7] = {
-1.964432669771684034858848142418228214855E-1L,
-1.333896496989238600119596538299938520726E-1L,
};
-#ifdef __STDC__
static const long double qs5[7] = {
-#else
-static long double qs5[7] = {
-#endif
6.552755584474634766937589285426911075101E-7L,
9.410814032118155978663509073200494000589E-5L,
4.561677087286518359461609153655021253238E-3L,
@@ -534,11 +446,7 @@ static long double qs5[7] = {
Q1(x) = z(.375 + z^2 R(z^2)), z=1/x
2.85711669921875 <= x <= 4.54541015625
Peak relative error 2.2e-21 */
-#ifdef __STDC__
static const long double qr3[7] = {
-#else
-static long double qr3[7] = {
-#endif
-3.618746299358445926506719188614570588404E-6L,
-2.951146018465419674063882650970344502798E-4L,
-7.728518171262562194043409753656506795258E-3L,
@@ -547,11 +455,7 @@ static long double qr3[7] = {
-4.858192581793118040782557808823460276452E-1L,
-1.592399251246473643510898335746432479373E-1L,
};
-#ifdef __STDC__
static const long double qs3[7] = {
-#else
-static long double qs3[7] = {
-#endif
3.529139957987837084554591421329876744262E-5L,
2.973602667215766676998703687065066180115E-3L,
8.273534546240864308494062287908662592100E-2L,
@@ -566,11 +470,7 @@ static long double qs3[7] = {
Q1(x) = z(.375 + z^2 R(z^2)), z=1/x
2 <= x <= 2.85711669921875
Peak relative error 6.9e-22 */
-#ifdef __STDC__
static const long double qr2[7] = {
-#else
-static long double qr2[7] = {
-#endif
-1.372751603025230017220666013816502528318E-4L,
-6.879190253347766576229143006767218972834E-3L,
-1.061253572090925414598304855316280077828E-1L,
@@ -579,11 +479,7 @@ static long double qr2[7] = {
-1.087955310491078933531734062917489870754E0L,
-1.826821119773182847861406108689273719137E-1L,
};
-#ifdef __STDC__
static const long double qs2[7] = {
-#else
-static long double qs2[7] = {
-#endif
1.338768933634451601814048220627185324007E-3L,
7.071099998918497559736318523932241901810E-2L,
1.200511429784048632105295629933382142221E0L,
@@ -595,20 +491,10 @@ static long double qs2[7] = {
};
-#ifdef __STDC__
static long double
qone (long double x)
-#else
-static long double
-qone (x)
- long double x;
-#endif
{
-#ifdef __STDC__
const long double *p, *q;
-#else
- long double *p, *q;
-#endif
static long double s, r, z;
int32_t ix;
u_int32_t se, i0, i1;