mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-11 07:40:05 +00:00
Format slowexp.c
This commit is contained in:
parent
8930ddc705
commit
2f22a1e8dd
@ -1,5 +1,8 @@
|
||||
2013-02-25 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||
|
||||
* sysdeps/ieee754/dbl-64/slowexp.c: Reformat in GNU coding
|
||||
style.
|
||||
|
||||
* sysdeps/ieee754/dbl-64/slowpow.c: Reformat in GNU coding
|
||||
style.
|
||||
|
||||
|
@ -34,32 +34,36 @@
|
||||
# define SECTION
|
||||
#endif
|
||||
|
||||
void __mpexp(mp_no *x, mp_no *y, int p);
|
||||
void __mpexp (mp_no *x, mp_no *y, int p);
|
||||
|
||||
/*Converting from double precision to Multi-precision and calculating e^x */
|
||||
double
|
||||
SECTION
|
||||
__slowexp(double x) {
|
||||
double w,z,res,eps=3.0e-26;
|
||||
__slowexp (double x)
|
||||
{
|
||||
double w, z, res, eps = 3.0e-26;
|
||||
int p;
|
||||
mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;
|
||||
mp_no mpx, mpy, mpz, mpw, mpeps, mpcor;
|
||||
|
||||
p=6;
|
||||
__dbl_mp(x,&mpx,p); /* Convert a double precision number x */
|
||||
/* into a multiple precision number mpx with prec. p. */
|
||||
__mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
|
||||
__dbl_mp(eps,&mpeps,p);
|
||||
__mul(&mpeps,&mpy,&mpcor,p);
|
||||
__add(&mpy,&mpcor,&mpw,p);
|
||||
__sub(&mpy,&mpcor,&mpz,p);
|
||||
__mp_dbl(&mpw, &w, p);
|
||||
__mp_dbl(&mpz, &z, p);
|
||||
if (w == z) return w;
|
||||
else { /* if calculating is not exactly */
|
||||
p = 32;
|
||||
__dbl_mp(x,&mpx,p);
|
||||
__mpexp(&mpx, &mpy, p);
|
||||
__mp_dbl(&mpy, &res, p);
|
||||
return res;
|
||||
}
|
||||
/* Use the multiple precision __MPEXP function to compute the exponential
|
||||
First at 144 bits and if it is not accurate enough, at 768 bits. */
|
||||
p = 6;
|
||||
__dbl_mp (x, &mpx, p);
|
||||
__mpexp (&mpx, &mpy, p);
|
||||
__dbl_mp (eps, &mpeps, p);
|
||||
__mul (&mpeps, &mpy, &mpcor, p);
|
||||
__add (&mpy, &mpcor, &mpw, p);
|
||||
__sub (&mpy, &mpcor, &mpz, p);
|
||||
__mp_dbl (&mpw, &w, p);
|
||||
__mp_dbl (&mpz, &z, p);
|
||||
if (w == z)
|
||||
return w;
|
||||
else
|
||||
{
|
||||
p = 32;
|
||||
__dbl_mp (x, &mpx, p);
|
||||
__mpexp (&mpx, &mpy, p);
|
||||
__mp_dbl (&mpy, &res, p);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user