diff options
Diffstat (limited to 'mathfuncs_asinh.h')
-rw-r--r-- | mathfuncs_asinh.h | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/mathfuncs_asinh.h b/mathfuncs_asinh.h index c7be8eb..1197261 100644 --- a/mathfuncs_asinh.h +++ b/mathfuncs_asinh.h @@ -7,36 +7,31 @@ #include <cmath> +namespace vecmathlib { +template <typename realvec_t> +realvec_t mathfuncs<realvec_t>::vml_asinh(realvec_t x) { + // 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_acosh(realvec_t x) { + return log(x + sqrt(x * x - RV(1.0))); +} + +template <typename realvec_t> +realvec_t mathfuncs<realvec_t>::vml_atanh(realvec_t 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 { - - template<typename realvec_t> - realvec_t mathfuncs<realvec_t>::vml_asinh(realvec_t x) - { - // 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_acosh(realvec_t x) - { - return log(x + sqrt(x*x - RV(1.0))); - } - - template<typename realvec_t> - realvec_t mathfuncs<realvec_t>::vml_atanh(realvec_t 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 -#endif // #ifndef MATHFUNCS_ASINH_H +#endif // #ifndef MATHFUNCS_ASINH_H |