Mercurial > mxe-octave
view src/build-msvctools/math/atanhf.c @ 5579:2734b3818171
Avoid double-free with librsb (bug #58957).
* src/librsb.mk: Add work-around to avoid double-free (provided by Michele
Martone).
* src/mingw-of-sparsersb-1-no-render.patch: Remove patch.
* dist-files.mk: Remove file from list.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 02 Nov 2020 08:55:18 +0100 |
parents | f8299bb6c872 |
children |
line wrap: on
line source
#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; }