Automatic Differentiation
 
Loading...
Searching...
No Matches
atanh.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ATANH_HPP
2#define STAN_MATH_PRIM_FUN_ATANH_HPP
3
11#include <cmath>
12#include <complex>
13
14namespace stan {
15namespace math {
16
27inline double atanh(double x) {
28 if (is_nan(x)) {
29 return x;
30 } else {
31 check_bounded("atanh", "x", x, -1.0, 1.0);
32 return std::atanh(x);
33 }
34}
35
43inline double atanh(int x) {
44 check_bounded("atanh", "x", x, -1, 1);
45 return std::atanh(x);
46}
47
51struct atanh_fun {
59 template <typename T>
60 static inline auto fun(const T& x) {
61 return atanh(x);
62 }
63};
64
75template <
76 typename T, require_not_var_matrix_t<T>* = nullptr,
78inline auto atanh(const T& x) {
80}
81
82namespace internal {
90template <typename V>
91inline std::complex<V> complex_atanh(const std::complex<V>& z) {
92 std::complex<double> y_d = atanh(value_of_rec(z));
93 V one(1);
94 auto y = 0.5 * (log(one + z) - log(one - z));
95 return copysign(y, y_d);
96}
97} // namespace internal
98
99} // namespace math
100} // namespace stan
101
102#endif
require_all_not_t< is_nonscalar_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_not_nonscalar_prim_or_rev_kernel_expression_t
Require none of the types satisfy is_nonscalar_prim_or_rev_kernel_expression.
require_not_t< is_var_matrix< std::decay_t< T > > > require_not_var_matrix_t
Require type does not satisfy is_var_matrix.
std::complex< V > complex_atanh(const std::complex< V > &z)
Return the hyperbolic arc tangent of the complex argument.
Definition atanh.hpp:91
double copysign(double a, double_d b)
Definition double_d.hpp:329
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
bool is_nan(T &&x)
Returns 1 if the input's value is NaN and 0 otherwise.
Definition is_nan.hpp:22
fvar< T > atanh(const fvar< T > &x)
Return inverse hyperbolic tangent of specified value.
Definition atanh.hpp:24
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static auto fun(const T &x)
Return the inverse hyperbolic tangent of the specified argument.
Definition atanh.hpp:60
Structure to wrap atanh() so it can be vectorized.
Definition atanh.hpp:51