summaryrefslogtreecommitdiffstats
path: root/mathfuncs_asinh.h
blob: 119726147d5c994553b7f4f4aaaf655ae3d42a6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// -*-C++-*-

#ifndef MATHFUNCS_ASINH_H
#define MATHFUNCS_ASINH_H

#include "mathfuncs_base.h"

#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

#endif // #ifndef MATHFUNCS_ASINH_H
OpenPOWER on IntegriCloud