diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-02-27 11:24:45 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-02-27 11:24:45 +0530 |
commit | 11d6e2f2372c4df6bc79aebf6e6f84c43dd0994d (patch) | |
tree | 949d11ca2495d90dd55853564e388c581549a4ac /sysdeps | |
parent | 90f42071e3d7d7d595fcd15c7241e7be46b2c2bd (diff) | |
download | glibc-11d6e2f2372c4df6bc79aebf6e6f84c43dd0994d.tar.gz glibc-11d6e2f2372c4df6bc79aebf6e6f84c43dd0994d.tar.xz glibc-11d6e2f2372c4df6bc79aebf6e6f84c43dd0994d.zip |
Format mplog.c
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/ieee754/dbl-64/mplog.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sysdeps/ieee754/dbl-64/mplog.c b/sysdeps/ieee754/dbl-64/mplog.c index e3d10846e2..f8d5c1095f 100644 --- a/sysdeps/ieee754/dbl-64/mplog.c +++ b/sysdeps/ieee754/dbl-64/mplog.c @@ -1,4 +1,3 @@ - /* * IBM Accurate Mathematical Library * written by International Business Machines Corp. @@ -37,27 +36,30 @@ #include "endian.h" #include "mpa.h" -void __mpexp(mp_no *, mp_no *, int); - -void __mplog(mp_no *x, mp_no *y, int p) { - int i,m; - static const int mp[33] = {0,0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4}; - mp_no mpt1,mpt2; +void +__mplog (mp_no *x, mp_no *y, int p) +{ + int i, m; + static const int mp[33] = + { + 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 + }; + mp_no mpt1, mpt2; - /* Choose m */ + /* Choose m. */ m = mp[p]; - /* Perform m newton iterations to solve for y: exp(y)-x=0. */ - /* The iterations formula is: y(n+1)=y(n)+(x*exp(-y(n))-1). */ - __cpy(y,&mpt1,p); - for (i=0; i<m; i++) { - mpt1.d[0]=-mpt1.d[0]; - __mpexp(&mpt1,&mpt2,p); - __mul(x,&mpt2,&mpt1,p); - __sub(&mpt1,&mpone,&mpt2,p); - __add(y,&mpt2,&mpt1,p); - __cpy(&mpt1,y,p); - } - return; + /* Perform m newton iterations to solve for y: exp(y) - x = 0. The + iterations formula is: y(n + 1) = y(n) + (x * exp(-y(n)) - 1). */ + __cpy (y, &mpt1, p); + for (i = 0; i < m; i++) + { + mpt1.d[0] = -mpt1.d[0]; + __mpexp (&mpt1, &mpt2, p); + __mul (x, &mpt2, &mpt1, p); + __sub (&mpt1, &mpone, &mpt2, p); + __add (y, &mpt2, &mpt1, p); + __cpy (&mpt1, y, p); + } } |