Elliott Hughes | a0ee078 | 2013-01-30 19:06:37 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * ==================================================== |
| 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
| 4 | * |
| 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
| 6 | * Permission to use, copy, modify, and distribute this |
| 7 | * software is freely granted, provided that this notice |
| 8 | * is preserved. |
| 9 | * ==================================================== |
| 10 | */ |
| 11 | |
| 12 | #include <sys/cdefs.h> |
| 13 | __FBSDID("$FreeBSD$"); |
| 14 | |
| 15 | /* |
| 16 | * Float version of k_log.h. See the latter for most comments. |
| 17 | */ |
| 18 | |
| 19 | static const float |
| 20 | /* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ |
| 21 | Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ |
| 22 | Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ |
| 23 | Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ |
| 24 | Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ |
| 25 | |
| 26 | static inline float |
| 27 | k_log1pf(float f) |
| 28 | { |
| 29 | float hfsq,s,z,R,w,t1,t2; |
| 30 | |
| 31 | s = f/((float)2.0+f); |
| 32 | z = s*s; |
| 33 | w = z*z; |
| 34 | t1= w*(Lg2+w*Lg4); |
| 35 | t2= z*(Lg1+w*Lg3); |
| 36 | R = t2+t1; |
| 37 | hfsq=(float)0.5*f*f; |
| 38 | return s*(hfsq+R); |
| 39 | } |