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
26inline double acosh(double x) {
27 if (is_nan(x)) {
28 return x;
29 } else {
30 check_greater_or_equal("acosh", "x", x, 1.0);
31#ifdef _WIN32
32 if (is_inf(x))
33 return x;
34#endif
35 return std::acosh(x);
36 }
37}
38
46inline double acosh(int x) {
47 if (is_nan(x)) {
48 return x;
49 } else {
50 check_greater_or_equal("acosh", "x", x, 1);
51#ifdef _WIN32
52 if (is_inf(x))
53 return x;
54#endif
55 return std::acosh(x);
56 }
57}
58
62struct acosh_fun {
70 template <typename T>
71 static inline auto fun(const T& x) {
72 return acosh(x);
73 }
74};
75
86template <
87 typename T, require_not_var_matrix_t<T>* = nullptr,
89inline auto acosh(const T& x) {
91}
92
93namespace internal {
94
102template <typename V>
103inline std::complex<V> complex_acosh(const std::complex<V>& z) {
104 std::complex<double> y_d = acosh(value_of_rec(z));
105 auto y = log(z + sqrt(z * z - 1));
106 return copysign(y, y_d);
107}
108
109} // namespace internal
110
111} // namespace math
112} // namespace stan
113
114#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.
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:103
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:15
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:17
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 ...
Definition fvar.hpp:9
static auto fun(const T &x)
Return the inverse hyperbolic cosine of the specified argument.
Definition acosh.hpp:71
Structure to wrap acosh() so it can be vectorized.
Definition acosh.hpp:62
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...