diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2004-10-07 00:31:32 +0400 |
---|---|---|
committer | Danny Smith <dannysmith@users.sourceforge.net> | 2004-10-07 00:31:32 +0400 |
commit | 72db1c11e9887439125ce798bb1b6d571fe7d840 (patch) | |
tree | 9ad7335a58ca086ea29b788d867728ea23fb7cc9 /winsup/mingw/mingwex/math/atanhf.c | |
parent | 74b2bdc351dcbab192faca58b5544bce4f92b973 (diff) |
* include/math.h (ashinh, asinhf, asinhl, acosh, acoshf, acoshl,
atanh, atanhf, atanhl): Add prototypes.
* mingwex/Makefile.in (MATH_OBJS): Add objects for above to list.
(MATH_DISTFILES): Add sources for above and fastmath.h to list.
Specify dependency on fastmath.h for new objects.
* mingwex/math/fastmath.h: New file.
* mingwex/math/ashinh.c: New file.
* mingwex/math/asinhf.c: New file.
* mingwex/math/asinhl.c: New file.
* mingwex/math/acosh.c: New file.
* mingwex/math/acoshf.c: New file.
* mingwex/math/acoshl.c: New file.
* mingwex/math/atanh.c: New file.
* mingwex/math/atanhf.c: New file.
* mingwex/math/atanhl.c: New file.
Diffstat (limited to 'winsup/mingw/mingwex/math/atanhf.c')
-rwxr-xr-x | winsup/mingw/mingwex/math/atanhf.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/winsup/mingw/mingwex/math/atanhf.c b/winsup/mingw/mingwex/math/atanhf.c new file mode 100755 index 000000000..b7c30823e --- /dev/null +++ b/winsup/mingw/mingwex/math/atanhf.c @@ -0,0 +1,30 @@ +#include <math.h> +#include <errno.h> +#include "fastmath.h" + +/* atanh (x) = 0.5 * log ((1.0 + x)/(1.0 - x)) */ +float atanhf (float x) +{ + float z; + if isnan (x) + return x; + z = fabsf (x); + if (z == 1.0) + { + errno = ERANGE; + return (x > 0 ? INFINITY : -INFINITY); + } + if ( z > 1.0) + { + errno = EDOM; + return nanf(""); + } + /* Rearrange formula to avoid precision loss for small x. + + atanh(x) = 0.5 * log ((1.0 + x)/(1.0 - x)) + = 0.5 * log1p ((1.0 + x)/(1.0 - x) - 1.0) + = 0.5 * log1p ((1.0 + x - 1.0 + x) /(1.0 - x)) + = 0.5 * log1p ((2.0 * x ) / (1.0 - x)) */ + z = 0.5 * __fast_log1p ((z + z) / (1.0 - z)); + return x >= 0 ? z : -z; +} |