diff options
Diffstat (limited to 'mathfuncs_asinh.h')
-rw-r--r-- | mathfuncs_asinh.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mathfuncs_asinh.h b/mathfuncs_asinh.h index 6ea7efd..754f5d7 100644 --- a/mathfuncs_asinh.h +++ b/mathfuncs_asinh.h @@ -21,13 +21,21 @@ namespace vecmathlib { template<typename realvec_t> realvec_t mathfuncs<realvec_t>::vml_asinh(realvec_t x) { - return log(x + sqrt(x*x + RV(1.0))); + // Reduce range + realvec_t r = fabs(x); + r = log(r + sqrt(r*r + RV(1.0))); + r = copysign(r, x); + return r; } template<typename realvec_t> realvec_t mathfuncs<realvec_t>::vml_atanh(realvec_t x) { - return RV(0.5) * log((RV(1.0) + x) / (RV(1.0) - x)); + // Reduce range + realvec_t r = fabs(x); + r = RV(0.5) * log((RV(1.0) + r) / (RV(1.0) - r)); + r = copysign(r, x); + return r; } }; // namespace vecmathlib |