123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #include "cdefs-compat.h"
- #include <openlibm_math.h>
- #include "mathimpl.h"
- static const double p1 = 0x1.555555555553ep-3;
- static const double p2 = -0x1.6c16c16bebd93p-9;
- static const double p3 = 0x1.1566aaf25de2cp-14;
- static const double p4 = -0x1.bbd41c5d26bf1p-20;
- static const double p5 = 0x1.6376972bea4d0p-25;
- static const double ln2hi = 0x1.62e42fee00000p-1;
- static const double ln2lo = 0x1.a39ef35793c76p-33;
- static const double lnhuge = 0x1.6602b15b7ecf2p9;
- static const double lntiny = -0x1.77af8ebeae354p9;
- static const double invln2 = 0x1.71547652b82fep0;
- #if 0
- DLLEXPORT double exp(x)
- double x;
- {
- double z,hi,lo,c;
- int k;
- #if !defined(vax)&&!defined(tahoe)
- if(x!=x) return(x);
- #endif
- if( x <= lnhuge ) {
- if( x >= lntiny ) {
-
- k=invln2*x+copysign(0.5,x);
-
- hi=x-k*ln2hi;
- x=hi-(lo=k*ln2lo);
-
- z=x*x;
- c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
- return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
- }
-
- else
-
- if(finite(x)) return(scalb(1.0,-5000));
-
- else return(0.0);
- }
-
- else
-
- return( finite(x) ? scalb(1.0,5000) : x);
- }
- #endif
- double __exp__D(x, c)
- double x, c;
- {
- double z,hi,lo;
- int k;
- if (x != x)
- return(x);
- if ( x <= lnhuge ) {
- if ( x >= lntiny ) {
-
- z = invln2*x;
- k = z + copysign(.5, x);
-
- hi=(x-k*ln2hi);
- x= hi - (lo = k*ln2lo-c);
-
- z=x*x;
- c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
- c = (x*c)/(2.0-c);
- return scalbn(1.+(hi-(lo - c)), k);
- }
-
- else
-
- if(isfinite(x)) return(scalbn(1.0,-5000));
-
- else return(0.0);
- }
-
- else
-
- return( isfinite(x) ? scalbn(1.0,5000) : x);
- }
|