12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "math.h"
- #include "math_private.h"
- static const u_int32_t
- B1 = 715094163,
- B2 = 696219795;
- static const double
- C = 5.42857142857142815906e-01,
- D = -7.05306122448979611050e-01,
- E = 1.41428571428571436819e+00,
- F = 1.60714285714285720630e+00,
- G = 3.57142857142857150787e-01;
- double cbrt(double x)
- {
- int32_t hx;
- double r,s,t=0.0,w;
- u_int32_t sign;
- u_int32_t high,low;
- GET_HIGH_WORD(hx,x);
- sign=hx&0x80000000;
- hx ^=sign;
- if(hx>=0x7ff00000) return(x+x);
- GET_LOW_WORD(low,x);
- if((hx|low)==0)
- return(x);
- SET_HIGH_WORD(x,hx);
-
- if(hx<0x00100000)
- {SET_HIGH_WORD(t,0x43500000);
- t*=x; GET_HIGH_WORD(high,t); SET_HIGH_WORD(t,high/3+B2);
- }
- else
- SET_HIGH_WORD(t,hx/3+B1);
-
- r=t*t/x;
- s=C+r*t;
- t*=G+F/(s+E+D/s);
-
- GET_HIGH_WORD(high,t);
- INSERT_WORDS(t,high+0x00000001,0);
-
- s=t*t;
- r=x/s;
- w=t+t;
- r=(r-t)/(w+r);
- t=t+t*r;
-
- GET_HIGH_WORD(high,t);
- SET_HIGH_WORD(t,high|sign);
- return(t);
- }
- libm_hidden_def(cbrt)
|