Automatic Differentiation
 
Loading...
Searching...
No Matches
acosh.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ACOSH_HPP
2#define STAN_MATH_PRIM_FUN_ACOSH_HPP
3
12#include <cmath>
13#include <complex>
14
15namespace stan {
16namespace math {
17
26template <typename T, require_arithmetic_t<T>* = nullptr>
27inline double acosh(const T x) {
28 if (is_nan(x)) {
29 return x;
30 } else {
31 check_greater_or_equal("acosh", "x", x, 1.0);
32#ifdef _WIN32
33 if (is_inf(x))
34 return x;
35#endif
36 return std::acosh(x);
37 }
38}
39
48template <typename T, require_complex_bt<std::is_arithmetic, T>* = nullptr>
49inline auto acosh(const T x) {
50 return std::acosh(x);
51}
52
56struct acosh_fun {
64 template <typename T>
65 static inline auto fun(const T& x) {
66 return acosh(x);
67 }
68};
69
80template <typename T, require_ad_container_t<T>* = nullptr>
81inline auto acosh(const T& x) {
83}
84
95template <typename Container,
97inline auto acosh(const Container& x) {
99}
100
101namespace internal {
102
110template <typename V>
111inline std::complex<V> complex_acosh(const std::complex<V>& z) {
112 std::complex<double> y_d = acosh(value_of_rec(z));
113 auto y = log(z + sqrt(z * z - 1));
114 return copysign(y, y_d);
115}
116
117} // namespace internal
118
119} // namespace math
120} // namespace stan
121
122#endif
require_t< container_type_check_base< is_container, base_type_t, TypeCheck, Check... > > require_container_bt
Require type satisfies is_container.
double copysign(double a, double_d b)
Definition double_d.hpp:329
std::complex< V > complex_acosh(const std::complex< V > &z)
Return the hyperbolic arc cosine of the complex argument.
Definition acosh.hpp:111
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > acosh(const fvar< T > &x)
Definition acosh.hpp:16
bool is_nan(T &&x)
Returns 1 if the input's value is NaN and 0 otherwise.
Definition is_nan.hpp:22
fvar< T > log(const fvar< T > &x)
Definition log.hpp:18
void check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low, Idxs... idxs)
Throw an exception if y is not greater or equal than low.
fvar< T > sqrt(const fvar< T > &x)
Definition sqrt.hpp:18
int is_inf(const fvar< T > &x)
Returns 1 if the input's value is infinite and 0 otherwise.
Definition is_inf.hpp:21
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static auto fun(const T &x)
Return the inverse hyperbolic cosine of the specified argument.
Definition acosh.hpp:65
Structure to wrap acosh() so it can be vectorized.
Definition acosh.hpp:56
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...