__log1pf.h 940 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* origin: FreeBSD /usr/src/lib/msun/src/k_logf.h */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /*
  13. * See comments in __log1p.h.
  14. */
  15. /* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
  16. static const float
  17. Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
  18. Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
  19. Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
  20. Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
  21. static inline float __log1pf(float f)
  22. {
  23. float hfsq,s,z,R,w,t1,t2;
  24. s = f/(2.0f + f);
  25. z = s*s;
  26. w = z*z;
  27. t1 = w*(Lg2+w*Lg4);
  28. t2 = z*(Lg1+w*Lg3);
  29. R = t2+t1;
  30. hfsq = 0.5f * f * f;
  31. return s*(hfsq+R);
  32. }