mirror of
https://git.planet-casio.com/Lephenixnoir/OpenLibm.git
synced 2024-12-29 13:03:42 +01:00
Import these fixes from upstream.
0563b7a42b/lib/msun/src/e_j0f.c
Fix test build on OS X.
This commit is contained in:
parent
c29e8b1b6e
commit
4c8740ad58
3 changed files with 27 additions and 39 deletions
31
src/e_j0f.c
31
src/e_j0f.c
|
@ -14,12 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "cdefs-compat.h"
|
#include "cdefs-compat.h"
|
||||||
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j0f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
|
|
||||||
|
|
||||||
#include <openlibm_math.h>
|
#include <openlibm_math.h>
|
||||||
|
|
||||||
#include "math_private.h"
|
#include "math_private.h"
|
||||||
|
|
||||||
static float pzerof(float), qzerof(float);
|
static float pzerof(float), qzerof(float);
|
||||||
|
@ -65,17 +62,17 @@ __ieee754_j0f(float x)
|
||||||
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
|
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
|
||||||
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
|
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
|
||||||
*/
|
*/
|
||||||
if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
|
if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(x); /* |x|>2**49 */
|
||||||
else {
|
else {
|
||||||
u = pzerof(x); v = qzerof(x);
|
u = pzerof(x); v = qzerof(x);
|
||||||
z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
|
z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
|
||||||
}
|
}
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if(ix<0x39000000) { /* |x| < 2**-13 */
|
if(ix<0x3b000000) { /* |x| < 2**-9 */
|
||||||
if(huge+x>one) { /* raise inexact if x != 0 */
|
if(huge+x>one) { /* raise inexact if x != 0 */
|
||||||
if(ix<0x32000000) return one; /* |x|<2**-27 */
|
if(ix<0x39800000) return one; /* |x|<2**-12 */
|
||||||
else return one - (float)0.25*x*x;
|
else return one - x*x/4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = x*x;
|
z = x*x;
|
||||||
|
@ -139,14 +136,14 @@ __ieee754_y0f(float x)
|
||||||
if ((s*c)<zero) cc = z/ss;
|
if ((s*c)<zero) cc = z/ss;
|
||||||
else ss = z/cc;
|
else ss = z/cc;
|
||||||
}
|
}
|
||||||
if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
|
if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
|
||||||
else {
|
else {
|
||||||
u = pzerof(x); v = qzerof(x);
|
u = pzerof(x); v = qzerof(x);
|
||||||
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
|
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
|
||||||
}
|
}
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if(ix<=0x32000000) { /* x < 2**-27 */
|
if(ix<=0x39000000) { /* x < 2**-13 */
|
||||||
return(u00 + tpi*__ieee754_logf(x));
|
return(u00 + tpi*__ieee754_logf(x));
|
||||||
}
|
}
|
||||||
z = x*x;
|
z = x*x;
|
||||||
|
@ -227,7 +224,6 @@ static const float pS2[5] = {
|
||||||
1.4657617569e+01, /* 0x416a859a */
|
1.4657617569e+01, /* 0x416a859a */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Note: This function is only called for ix>=0x40000000 (see above) */
|
|
||||||
static float pzerof(float x)
|
static float pzerof(float x)
|
||||||
{
|
{
|
||||||
const float *p,*q;
|
const float *p,*q;
|
||||||
|
@ -235,11 +231,10 @@ static const float pS2[5] = {
|
||||||
int32_t ix;
|
int32_t ix;
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
ix &= 0x7fffffff;
|
ix &= 0x7fffffff;
|
||||||
assert(ix>=0x40000000 && ix<=0x48000000);
|
|
||||||
if(ix>=0x41000000) {p = pR8; q= pS8;}
|
if(ix>=0x41000000) {p = pR8; q= pS8;}
|
||||||
else if(ix>=0x40f71c58){p = pR5; q= pS5;}
|
else if(ix>=0x409173eb){p = pR5; q= pS5;}
|
||||||
else if(ix>=0x4036db68){p = pR3; q= pS3;}
|
else if(ix>=0x4036d917){p = pR3; q= pS3;}
|
||||||
else {p = pR2; q= pS2;}
|
else {p = pR2; q= pS2;} /* ix>=0x40000000 */
|
||||||
z = one/(x*x);
|
z = one/(x*x);
|
||||||
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
||||||
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
|
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
|
||||||
|
@ -324,7 +319,6 @@ static const float qS2[6] = {
|
||||||
-5.3109550476e+00, /* 0xc0a9f358 */
|
-5.3109550476e+00, /* 0xc0a9f358 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Note: This function is only called for ix>=0x40000000 (see above) */
|
|
||||||
static float qzerof(float x)
|
static float qzerof(float x)
|
||||||
{
|
{
|
||||||
const float *p,*q;
|
const float *p,*q;
|
||||||
|
@ -332,11 +326,10 @@ static const float qS2[6] = {
|
||||||
int32_t ix;
|
int32_t ix;
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
ix &= 0x7fffffff;
|
ix &= 0x7fffffff;
|
||||||
assert(ix>=0x40000000 && ix<=0x48000000);
|
|
||||||
if(ix>=0x41000000) {p = qR8; q= qS8;}
|
if(ix>=0x41000000) {p = qR8; q= qS8;}
|
||||||
else if(ix>=0x40f71c58){p = qR5; q= qS5;}
|
else if(ix>=0x409173eb){p = qR5; q= qS5;}
|
||||||
else if(ix>=0x4036db68){p = qR3; q= qS3;}
|
else if(ix>=0x4036d917){p = qR3; q= qS3;}
|
||||||
else {p = qR2; q= qS2;}
|
else {p = qR2; q= qS2;} /* ix>=0x40000000 */
|
||||||
z = one/(x*x);
|
z = one/(x*x);
|
||||||
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
||||||
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
|
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
|
||||||
|
|
30
src/e_j1f.c
30
src/e_j1f.c
|
@ -14,12 +14,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "cdefs-compat.h"
|
#include "cdefs-compat.h"
|
||||||
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j1f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
|
|
||||||
|
|
||||||
#include <openlibm_math.h>
|
#include <openlibm_math.h>
|
||||||
|
|
||||||
#include "math_private.h"
|
#include "math_private.h"
|
||||||
|
|
||||||
static float ponef(float), qonef(float);
|
static float ponef(float), qonef(float);
|
||||||
|
@ -66,7 +62,7 @@ __ieee754_j1f(float x)
|
||||||
* j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(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)
|
* y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
|
||||||
*/
|
*/
|
||||||
if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
|
if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(y); /* |x|>2**49 */
|
||||||
else {
|
else {
|
||||||
u = ponef(y); v = qonef(y);
|
u = ponef(y); v = qonef(y);
|
||||||
z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
|
z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
|
||||||
|
@ -74,7 +70,7 @@ __ieee754_j1f(float x)
|
||||||
if(hx<0) return -z;
|
if(hx<0) return -z;
|
||||||
else return z;
|
else return z;
|
||||||
}
|
}
|
||||||
if(ix<0x32000000) { /* |x|<2**-27 */
|
if(ix<0x39000000) { /* |x|<2**-13 */
|
||||||
if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
|
if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
|
||||||
}
|
}
|
||||||
z = x*x;
|
z = x*x;
|
||||||
|
@ -132,14 +128,14 @@ __ieee754_y1f(float x)
|
||||||
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
|
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
|
||||||
* to compute the worse one.
|
* to compute the worse one.
|
||||||
*/
|
*/
|
||||||
if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
|
if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
|
||||||
else {
|
else {
|
||||||
u = ponef(x); v = qonef(x);
|
u = ponef(x); v = qonef(x);
|
||||||
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
|
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
|
||||||
}
|
}
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if(ix<=0x24800000) { /* x < 2**-54 */
|
if(ix<=0x33000000) { /* x < 2**-25 */
|
||||||
return(-tpi/x);
|
return(-tpi/x);
|
||||||
}
|
}
|
||||||
z = x*x;
|
z = x*x;
|
||||||
|
@ -222,7 +218,6 @@ static const float ps2[5] = {
|
||||||
8.3646392822e+00, /* 0x4105d590 */
|
8.3646392822e+00, /* 0x4105d590 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Note: This function is only called for ix>=0x40000000 (see above) */
|
|
||||||
static float ponef(float x)
|
static float ponef(float x)
|
||||||
{
|
{
|
||||||
const float *p,*q;
|
const float *p,*q;
|
||||||
|
@ -230,11 +225,10 @@ static const float ps2[5] = {
|
||||||
int32_t ix;
|
int32_t ix;
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
ix &= 0x7fffffff;
|
ix &= 0x7fffffff;
|
||||||
assert(ix>=0x40000000 && ix<=0x48000000);
|
|
||||||
if(ix>=0x41000000) {p = pr8; q= ps8;}
|
if(ix>=0x41000000) {p = pr8; q= ps8;}
|
||||||
else if(ix>=0x40f71c58){p = pr5; q= ps5;}
|
else if(ix>=0x409173eb){p = pr5; q= ps5;}
|
||||||
else if(ix>=0x4036db68){p = pr3; q= ps3;}
|
else if(ix>=0x4036d917){p = pr3; q= ps3;}
|
||||||
else {p = pr2; q= ps2;}
|
else {p = pr2; q= ps2;} /* ix>=0x40000000 */
|
||||||
z = one/(x*x);
|
z = one/(x*x);
|
||||||
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
||||||
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
|
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
|
||||||
|
@ -320,7 +314,6 @@ static const float qs2[6] = {
|
||||||
-4.9594988823e+00, /* 0xc09eb437 */
|
-4.9594988823e+00, /* 0xc09eb437 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Note: This function is only called for ix>=0x40000000 (see above) */
|
|
||||||
static float qonef(float x)
|
static float qonef(float x)
|
||||||
{
|
{
|
||||||
const float *p,*q;
|
const float *p,*q;
|
||||||
|
@ -328,11 +321,10 @@ static const float qs2[6] = {
|
||||||
int32_t ix;
|
int32_t ix;
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
ix &= 0x7fffffff;
|
ix &= 0x7fffffff;
|
||||||
assert(ix>=0x40000000 && ix<=0x48000000);
|
if(ix>=0x41000000) {p = qr8; q= qs8;}
|
||||||
if(ix>=0x40200000) {p = qr8; q= qs8;}
|
else if(ix>=0x409173eb){p = qr5; q= qs5;}
|
||||||
else if(ix>=0x40f71c58){p = qr5; q= qs5;}
|
else if(ix>=0x4036d917){p = qr3; q= qs3;}
|
||||||
else if(ix>=0x4036db68){p = qr3; q= qs3;}
|
else {p = qr2; q= qs2;} /* ix>=0x40000000 */
|
||||||
else {p = qr2; q= qs2;}
|
|
||||||
z = one/(x*x);
|
z = one/(x*x);
|
||||||
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
|
||||||
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
|
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
|
||||||
|
|
|
@ -2,7 +2,10 @@ OPENLIBM_HOME=$(abspath ..)
|
||||||
include ../Make.inc
|
include ../Make.inc
|
||||||
|
|
||||||
# Set rpath of tests to builddir for loading shared library
|
# Set rpath of tests to builddir for loading shared library
|
||||||
OPENLIBM_LIB = -L.. -lopenlibm -Wl,-rpath=$(OPENLIBM_HOME)
|
OPENLIBM_LIB = -L.. -lopenlibm
|
||||||
|
ifeq ($(OS),Linux)
|
||||||
|
OPENLIBM_LIB += -Wl,-rpath=$(OPENLIBM_HOME)
|
||||||
|
endif
|
||||||
|
|
||||||
all: test-double test-float # test-double-system test-float-system
|
all: test-double test-float # test-double-system test-float-system
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue