e_atan2, e_fmod, e_log, and e_log10 100%

This commit is contained in:
shibbo 2023-03-01 03:12:43 -05:00
parent 26522ad64f
commit 983a0b91fc
9 changed files with 425 additions and 16 deletions

View File

@ -103,10 +103,10 @@ strncasecmp,extras.o,MSL_C.PPCEABI.bare.H.a,false
strcasecmp,extras.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_acos,e_acos.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_asin,e_asin.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_atan2,e_atan2.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_fmod,e_fmod.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_log,e_log.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_log10,e_log10.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_atan2,e_atan2.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_fmod,e_fmod.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_log,e_log.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_log10,e_log10.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_pow,e_pow.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_rem_pio2,e_rem_pio2.o,MSL_C.PPCEABI.bare.H.a,true
__kernel_cos,k_cos.o,MSL_C.PPCEABI.bare.H.a,true

1 Symbol Name Object File Library Archive Matching
103 strcasecmp extras.o MSL_C.PPCEABI.bare.H.a false
104 __ieee754_acos e_acos.o MSL_C.PPCEABI.bare.H.a true
105 __ieee754_asin e_asin.o MSL_C.PPCEABI.bare.H.a true
106 __ieee754_atan2 e_atan2.o MSL_C.PPCEABI.bare.H.a false true
107 __ieee754_fmod e_fmod.o MSL_C.PPCEABI.bare.H.a false true
108 __ieee754_log e_log.o MSL_C.PPCEABI.bare.H.a false true
109 __ieee754_log10 e_log10.o MSL_C.PPCEABI.bare.H.a false true
110 __ieee754_pow e_pow.o MSL_C.PPCEABI.bare.H.a false
111 __ieee754_rem_pio2 e_rem_pio2.o MSL_C.PPCEABI.bare.H.a true
112 __kernel_cos k_cos.o MSL_C.PPCEABI.bare.H.a true

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "MSL",
"message": "39.205%",
"message": "43.075%",
"color": "blue"
}

View File

@ -1,3 +1,3 @@
| Library | Percentage |
| ------------- | ------------- |
| [MSL_C.PPCEABI.bare.H](https://github.com/shibbo/Petari/blob/master/libs/MSL_C/docs/lib/MSL_C.PPCEABI.bare.H.md) | 39.205349106339206% |
| [MSL_C.PPCEABI.bare.H](https://github.com/shibbo/Petari/blob/master/libs/MSL_C/docs/lib/MSL_C.PPCEABI.bare.H.md) | 43.075736145043074% |

View File

@ -38,10 +38,10 @@
| extras.o | 0.0% | 0 / 3 | 0.0% | :x:
| e_acos.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_asin.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_atan2.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_fmod.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_log.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_log10.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_atan2.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_fmod.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_log.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_log10.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_pow.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_rem_pio2.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| k_cos.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
@ -325,25 +325,25 @@
# e_atan2.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ieee754_atan2 | :x: |
| __ieee754_atan2 | :white_check_mark: |
# e_fmod.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ieee754_fmod | :x: |
| __ieee754_fmod | :white_check_mark: |
# e_log.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ieee754_log | :x: |
| __ieee754_log | :white_check_mark: |
# e_log10.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ieee754_log10 | :x: |
| __ieee754_log10 | :white_check_mark: |
# e_pow.o

View File

@ -2,10 +2,10 @@
#define CMATH_H
#ifdef __cplusplus
namespace std {
extern "C" {
#endif
double atan(double);
double atan2(double, double);
double ceil(double);
double floor(double);
@ -13,6 +13,11 @@ double frexp(double, int *);
double ldexp(double, int);
double sqrt(double);
double log(double);
double log10(double);
double __ieee754_log(double);
double scalbn(double, int);
int __float_huge[];
@ -23,7 +28,6 @@ int __float_nan[];
#ifdef __cplusplus
};
};
#endif
#endif // CMATH_H

100
libs/MSL_C/source/e_atan2.c Normal file
View File

@ -0,0 +1,100 @@
#include <cmath>
double __ieee754_atan2(double y, double x) {
double z;
int k, m, hx, hy, ix, iy;
unsigned int lx, ly;
hx = *(int*)&x;
ix = hx & 0x7FFFFFFF;
lx = *(1 + (int*)&x);
hy = *(int*)&y;
iy = hy & 0x7FFFFFFF;
ly = *(1 + (int*)&y);
if(((ix | ((lx | -lx) >> 31)) > 0x7ff00000) || ((iy | ((ly | -ly) >> 31)) > 0x7ff00000)) {
return x+ y;
}
if ((hx - 0x3FF00000 | lx) == 0) {
return atan(y);
}
m = ((hy >> 31) & 0x1) | ((hx >> 30) & 0x2);
if ((iy | ly) == 0) {
switch (m) {
case 0:
case 1:
return y;
case 2:
return 3.1415926535897931160E+00 + 1.0e-300;
case 3:
return -3.1415926535897931160E+00 - 1.0e-300;
}
}
if ((ix | lx) == 0) {
if (hy < 0) {
return -1.5707963267948965580E+00 - 1.0e-300;
}
else {
return 1.5707963267948965580E+00 + 1.0e-300;
}
}
if (ix == 0x7FF00000) {
if (iy == 0x7FF00000) {
switch (m) {
case 0:
return 7.8539816339744827900E-01 + 1.0e-300;
case 1:
return -7.8539816339744827900E-01 - 1.0e-300;
case 2:
return 3.0 * 7.8539816339744827900E-01 + 1.0e-300;
case 3:
return -3.0 * 7.8539816339744827900E-01 - 1.0e-300;
}
}
else {
switch (m) {
case 0:
return 0.0;
case 1:
return -0.0;
case 2:
return 3.1415926535897931160E+00 + 1.0e-300;
case 3:
return -3.1415926535897931160E+00 - 1.0e-300;
}
}
}
if (iy == 0x7FF00000) {
return (hy < 0) ? -1.5707963267948965580E+00 - 1.0e-300 : 1.5707963267948965580E+00 + -1.0e-300;
}
k = (iy - ix) >> 20;
if (k > 60) {
z = 1.5707963267948965580E+00 + 0.5 * 1.2246467991473531772E-16;
}
else if (hx < 0 && k < -60) {
z = 0.0;
}
else {
z = atan(__fabs(y / x));
}
switch (m) {
case 0:
return z;
case 1:
*(int*)&z ^= 0x80000000;
return z;
case 2:
return 3.1415926535897931160E+00 - (z - 1.2246467991473531772E-16);
default:
return (z - 1.2246467991473531772E-16) - 3.1415926535897931160E+00;
}
}

162
libs/MSL_C/source/e_fmod.c Normal file
View File

@ -0,0 +1,162 @@
static const double one = 1.0;
static const double Zero[] = {0.0, -0.0};
double __ieee754_fmod(double x, double y) {
int n, hx, hy, hz, ix, iy, sx, i;
unsigned int lx, ly, lz;
hx = *(int*)&x;
lx = *(1 + (int*)&x);
hy = *(int*)&y;
ly = *(1 + (int*)&y);
sx = hx & 0x80000000;
hx ^= sx;
hy &= 0x7FFFFFFF;
if ((hy | ly) == 0 || (hx >= 0x7FF00000) || ((hy | ((ly | -ly) >> 31)) > 0x7FF00000)) {
return (x * y) / (x * y);
}
if (hx <= hy) {
if ((hx < hy) || (lx < ly)) {
return x;
}
if (lx == ly) {
return Zero[(unsigned int)sx >> 31];
}
}
if (hx < 0x100000) {
if (hx == 0) {
for (ix = -1043, i = lx; i > 0; i <<= 1) {
ix -= 1;
}
}
else {
for (ix = -1022, i = (hx << 11); i > 0; i <<= 1) {
ix -= 1;
}
}
}
else {
ix = (hx >> 20) - 1023;
}
if (hy < 0x00100000) {
if (hy == 0) {
for (iy = -1043, i = ly; i > 0; i <<= 1) {
iy -=1;
}
}
else {
for (iy = -1022, i = (hy << 11); i > 0; i <<= 1) {
iy -= 1;
}
}
}
else {
iy = (hy >> 20) - 1023;
}
if (ix >= -1022) {
hx = 0x100000 | (0xFFFFF & hx);
}
else {
n = -1022 - ix;
if (n <= 31) {
hx = (hx << n) | (lx >> (32 - n));
lx <<= n;
}
else {
hx = lx << (n - 32);
lx = 0;
}
}
if (iy >= -1022) {
hy = 0x100000 | (0xFFFFF & hy);
}
else {
n = -1022 - iy;
if (n <= 31) {
hy = (hy << n) | (ly >> (32 - n));
ly <<= n;
}
else {
hy = ly << (n - 32);
ly = 0;
}
}
n = ix - iy;
while(n--) {
hz= hx - hy;
lz= lx - ly;
if(lx < ly) {
hz -= 1;
}
if(hz < 0){
hx = hx + hx + (lx >> 31);
lx = lx + lx;
}
else {
if((hz | lz) == 0)
return Zero[(unsigned int) sx >> 31];
hx = hz + hz + (lz >> 31);
lx = lz + lz;
}
}
hz= hx - hy;
lz= lx - ly;
if(lx < ly) {
hz -= 1;
}
if(hz >= 0) {
hx = hz;
lx = lz;
}
if((hx | lx) == 0)
return Zero[(unsigned int)sx >> 31];
while(hx < 0x100000) {
hx = hx + hx + (lx >> 31);
lx = lx + lx;
iy -= 1;
}
if(iy>= -1022) {
hx = ((hx - 0x100000)|((iy + 1023) << 20));
*(int*)&x = hx | sx;
*(1 + (int*)&x) = lx;
}
else {
n = -1022 - iy;
if (n <= 20) {
lx = (lx >> n) | ((unsigned int)hx << (32 - n));
hx >>= n;
}
else if (n <= 31) {
lx = (hx << (32 - n)) | (lx >> n);
hx = sx;
}
else {
lx = hx >>(n - 32);
hx = sx;
}
*(int*)&x = hx | sx;
*(1 + (int*)&x) = lx;
x *= one;
}
return x;
}

101
libs/MSL_C/source/e_log.c Normal file
View File

@ -0,0 +1,101 @@
#include <cerrno>
static const double
ln2_hi = 6.93147180369123816490e-01,
ln2_lo = 1.90821492927058770002e-10,
two54 = 1.80143985094819840000e+16,
Lg1 = 6.666666666666735130e-01,
Lg2 = 3.999999999940941908e-01,
Lg3 = 2.857142874366239149e-01,
Lg4 = 2.222219843214978396e-01,
Lg5 = 1.818357216161805012e-01,
Lg6 = 1.531383769920937332e-01,
Lg7 = 1.479819860511658591e-01;
static double zero = 0.0;
double __ieee754_log(double x) {
double hfsq, f, s, z, R, w, t1, t2, dk;
int k, hx, i, j;
unsigned int lx;
hx = *(int*)&x;
lx = *(1 + (int*)&x);
k = 0;
if (hx < 0x00100000) {
if (((hx&0x7fffffff)|lx)==0) {
return -1.80143985094819840000e+16 / zero;
}
if (hx < 0) {
errno = 0x21;
return (x - x) / zero;
}
k -= 54;
x *= 1.80143985094819840000e+16;
hx = *(int*)&x;
}
if (hx >= 0x7FF00000) {
return x + x;
}
k += (hx >> 20) - 1023;
hx &= 0xFFFFF;
i = (hx + 0x95f64) & 0x100000;
*(int*)&x = hx | (i ^ 0x3FF00000);
k += (i >> 20);
f = x - 1.0;
if((0xFFFFF & (2 + hx))< 3) {
if(f == 0.0) {
if(k == 0) {
return 0.0;
}
else {
dk = (double)k;
return dk * 6.93147180369123816490e-01 + dk * 1.90821492927058770002e-10;
}
}
R = f * f * (0.5 - 0.33333333333333333 * f);
if (k == 0) {
return f - R;
}
else {
dk = (double)k;
return dk * 6.93147180369123816490e-01 - ((R - dk * 1.90821492927058770002e-10) - f);
}
}
s = f / (2.0 + f);
dk = (double)k;
z = s * s;
i = hx - 0x6147a;
w = z * z;
j = 0x6b851 - hx;
t1= w * (Lg2 + w * (Lg4 + w * Lg6));
t2= z *(Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
i |= j;
R = t2 + t1;
if(i > 0) {
hfsq = 0.5 * f * f;
if(k == 0) {
return f -(hfsq - s * (hfsq + R));
}
else {
return dk * ln2_hi - ((hfsq-(s * (hfsq + R) + dk * ln2_lo)) - f);
}
} else {
if(k == 0) {
return f-s*(f-R);
}
else {
return dk * ln2_hi-((s * (f - R) - dk * ln2_lo) - f);
}
}
}

View File

@ -0,0 +1,42 @@
#include <cmath>
#include <cerrno>
static double zero = 0.0;
double __ieee754_log10(double x) {
double y, z;
int i, k, hx;
unsigned int lx;
hx = *(int*)&x;
lx = *(1 + (int*)&x);
k = 0;
if (hx < 0x100000) {
if (((hx & 0x7FFFFFFF) | lx) == 0) {
errno = 0x21;
return -1.80143985094819840000e+16 / zero;
}
if (hx < 0) {
errno = 0x21;
return (x - x) / zero;
}
k -= 54;
x *= 1.80143985094819840000e+16;
hx = *(int*)&x;
}
if (hx >= 0x7FF00000) {
return x + x;
}
k += (hx >> 20) - 1023;
i = ((unsigned int)k & 0x80000000) >> 31;
hx = (hx & 0xFFFFF) | ((0x3FF - i) << 20);
y = (double)(k + i);
*(int*)&x = hx;
z = y * 3.69423907715893078616e-13 + 4.34294481903251816668e-01 * __ieee754_log(x);
return z + y * 3.01029995663611771306e-01;
}