Format mpatan.c
This commit is contained in:
parent
b8de22026d
commit
6295157a77
@ -1,5 +1,7 @@
|
||||
2013-02-27 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||
|
||||
* sysdeps/ieee754/dbl-64/mpatan.c: Reformat.
|
||||
|
||||
* sysdeps/ieee754/dbl-64/mptan.c: Reformat.
|
||||
|
||||
* sysdeps/ieee754/dbl-64/mplog.c: Reformat.
|
||||
|
@ -39,63 +39,78 @@
|
||||
|
||||
#include "mpatan.h"
|
||||
|
||||
void __mpsqrt(mp_no *, mp_no *, int);
|
||||
|
||||
void
|
||||
SECTION
|
||||
__mpatan(mp_no *x, mp_no *y, int p) {
|
||||
__mpatan (mp_no *x, mp_no *y, int p)
|
||||
{
|
||||
|
||||
int i,m,n;
|
||||
int i, m, n;
|
||||
double dx;
|
||||
mp_no
|
||||
mptwoim1 = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
|
||||
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
|
||||
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
|
||||
|
||||
mp_no mps,mpsm,mpt,mpt1,mpt2,mpt3;
|
||||
|
||||
/* Choose m and initiate mptwoim1 */
|
||||
if (EX>0) m=7;
|
||||
else if (EX<0) m=0;
|
||||
else {
|
||||
__mp_dbl(x,&dx,p); dx=ABS(dx);
|
||||
for (m=6; m>0; m--)
|
||||
{if (dx>__atan_xm[m].d) break;}
|
||||
mp_no mptwoim1 =
|
||||
{
|
||||
0,
|
||||
{
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
|
||||
}
|
||||
mptwoim1.e = 1;
|
||||
mptwoim1.d[0] = ONE;
|
||||
};
|
||||
|
||||
/* Reduce x m times */
|
||||
__sqr(x,&mpsm,p);
|
||||
if (m==0) __cpy(x,&mps,p);
|
||||
else {
|
||||
for (i=0; i<m; i++) {
|
||||
__add(&mpone,&mpsm,&mpt1,p);
|
||||
__mpsqrt(&mpt1,&mpt2,p);
|
||||
__add(&mpt2,&mpt2,&mpt1,p);
|
||||
__add(&mptwo,&mpsm,&mpt2,p);
|
||||
__add(&mpt1,&mpt2,&mpt3,p);
|
||||
__dvd(&mpsm,&mpt3,&mpt1,p);
|
||||
__cpy(&mpt1,&mpsm,p);
|
||||
}
|
||||
__mpsqrt(&mpsm,&mps,p); mps.d[0] = X[0];
|
||||
mp_no mps, mpsm, mpt, mpt1, mpt2, mpt3;
|
||||
|
||||
/* Choose m and initiate mptwoim1. */
|
||||
if (EX > 0)
|
||||
m = 7;
|
||||
else if (EX < 0)
|
||||
m = 0;
|
||||
else
|
||||
{
|
||||
__mp_dbl (x, &dx, p);
|
||||
dx = ABS (dx);
|
||||
for (m = 6; m > 0; m--)
|
||||
{
|
||||
if (dx > __atan_xm[m].d)
|
||||
break;
|
||||
}
|
||||
}
|
||||
mptwoim1.e = 1;
|
||||
mptwoim1.d[0] = ONE;
|
||||
|
||||
/* Reduce x m times. */
|
||||
__sqr (x, &mpsm, p);
|
||||
if (m == 0)
|
||||
__cpy (x, &mps, p);
|
||||
else
|
||||
{
|
||||
for (i = 0; i < m; i++)
|
||||
{
|
||||
__add (&mpone, &mpsm, &mpt1, p);
|
||||
__mpsqrt (&mpt1, &mpt2, p);
|
||||
__add (&mpt2, &mpt2, &mpt1, p);
|
||||
__add (&mptwo, &mpsm, &mpt2, p);
|
||||
__add (&mpt1, &mpt2, &mpt3, p);
|
||||
__dvd (&mpsm, &mpt3, &mpt1, p);
|
||||
__cpy (&mpt1, &mpsm, p);
|
||||
}
|
||||
__mpsqrt (&mpsm, &mps, p);
|
||||
mps.d[0] = X[0];
|
||||
}
|
||||
|
||||
/* Evaluate a truncated power series for Atan(s) */
|
||||
n=__atan_np[p]; mptwoim1.d[1] = __atan_twonm1[p].d;
|
||||
__dvd(&mpsm,&mptwoim1,&mpt,p);
|
||||
for (i=n-1; i>1; i--) {
|
||||
/* Evaluate a truncated power series for Atan(s). */
|
||||
n = __atan_np[p];
|
||||
mptwoim1.d[1] = __atan_twonm1[p].d;
|
||||
__dvd (&mpsm, &mptwoim1, &mpt, p);
|
||||
for (i = n - 1; i > 1; i--)
|
||||
{
|
||||
mptwoim1.d[1] -= TWO;
|
||||
__dvd(&mpsm,&mptwoim1,&mpt1,p);
|
||||
__mul(&mpsm,&mpt,&mpt2,p);
|
||||
__sub(&mpt1,&mpt2,&mpt,p);
|
||||
__dvd (&mpsm, &mptwoim1, &mpt1, p);
|
||||
__mul (&mpsm, &mpt, &mpt2, p);
|
||||
__sub (&mpt1, &mpt2, &mpt, p);
|
||||
}
|
||||
__mul(&mps,&mpt,&mpt1,p);
|
||||
__sub(&mps,&mpt1,&mpt,p);
|
||||
__mul (&mps, &mpt, &mpt1, p);
|
||||
__sub (&mps, &mpt1, &mpt, p);
|
||||
|
||||
/* Compute Atan(x) */
|
||||
mptwoim1.d[1] = 1 << m;
|
||||
__mul(&mptwoim1,&mpt,y,p);
|
||||
|
||||
return;
|
||||
/* Compute Atan(x). */
|
||||
mptwoim1.d[1] = 1 << m;
|
||||
__mul (&mptwoim1, &mpt, y, p);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user