123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #include <openlibm_math.h>
- static const long double MAXLOGL = 1.1356523406294143949492E4L;
- static const long double
- P0 = -1.586135578666346600772998894928250240826E4L,
- P1 = 2.642771505685952966904660652518429479531E3L,
- P2 = -3.423199068835684263987132888286791620673E2L,
- P3 = 1.800826371455042224581246202420972737840E1L,
- P4 = -5.238523121205561042771939008061958820811E-1L,
- Q0 = -9.516813471998079611319047060563358064497E4L,
- Q1 = 3.964866271411091674556850458227710004570E4L,
- Q2 = -7.207678383830091850230366618190187434796E3L,
- Q3 = 7.206038318724600171970199625081491823079E2L,
- Q4 = -4.002027679107076077238836622982900945173E1L,
-
- C1 = 6.93145751953125E-1L,
- C2 = 1.428606820309417232121458176568075500134E-6L,
- minarg = -4.5054566736396445112120088E1L;
- static const long double huge = 0x1p10000L;
- long double
- expm1l(long double x)
- {
- long double px, qx, xx;
- int k;
- if (x > MAXLOGL)
- return (huge*huge);
- if (x == 0.0)
- return x;
- if (x < minarg)
- return -1.0L;
- xx = C1 + C2;
- px = floorl (0.5 + x / xx);
- k = px;
- x -= px * C1;
- x -= px * C2;
- px = (((( P4 * x
- + P3) * x
- + P2) * x
- + P1) * x
- + P0) * x;
- qx = (((( x
- + Q4) * x
- + Q3) * x
- + Q2) * x
- + Q1) * x
- + Q0;
- xx = x * x;
- qx = x + (0.5 * xx + xx * px / qx);
- px = ldexpl(1.0L, k);
- x = px * qx + (px - 1.0);
- return x;
- }
|