OpenLibm/src/k_logf.h

40 lines
1.0 KiB
C
Raw Normal View History

2011-08-13 06:57:34 +02:00
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include "cdefs-compat.h"
2011-12-15 07:16:26 +01:00
//__FBSDID("$FreeBSD: src/lib/msun/src/k_logf.h,v 1.3 2011/10/15 05:23:28 das Exp $");
2011-08-13 06:57:34 +02:00
2011-12-15 06:59:35 +01:00
/*
* Float version of k_log.h. See the latter for most comments.
2011-08-13 06:57:34 +02:00
*/
static const float
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static inline float
2011-12-15 06:59:35 +01:00
k_log1pf(float f)
2011-08-13 06:57:34 +02:00
{
2011-12-15 06:59:35 +01:00
float hfsq,s,z,R,w,t1,t2;
2011-08-13 06:57:34 +02:00
s = f/((float)2.0+f);
z = s*s;
w = z*z;
t1= w*(Lg2+w*Lg4);
t2= z*(Lg1+w*Lg3);
R = t2+t1;
2011-12-15 06:59:35 +01:00
hfsq=(float)0.5*f*f;
return s*(hfsq+R);
2011-08-13 06:57:34 +02:00
}