Automatic Differentiation
 
Loading...
Searching...
No Matches
log1m_exp.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP_HPP
2#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP_HPP
3#ifdef STAN_OPENCL
4
6#include <string>
7
8namespace stan {
9namespace math {
10namespace opencl_kernels {
11
12// \cond
13static constexpr const char* log1m_exp_device_function
14 = "\n"
15 "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP\n"
16 "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP\n" STRINGIFY(
17 // \endcond
31 double log1m_exp(double a) {
32 if (a > -0.693147)
33 return log(-expm1(a)); // 0.693147 ~= log(2)
34 else
35 return log1p(-exp(a));
36 }
37 // \cond
38 ) "\n#endif\n"; // NOLINT
39// \endcond
40
41} // namespace opencl_kernels
42} // namespace math
43} // namespace stan
44
45#endif
46#endif
double log1m_exp(double a)
Calculates the natural logarithm of one minus the exponential of the specified value without overflow...
Definition log1m_exp.hpp:31
fvar< T > expm1(const fvar< T > &x)
Definition expm1.hpp:14
fvar< T > log(const fvar< T > &x)
Definition log.hpp:18
fvar< T > log1p(const fvar< T > &x)
Definition log1p.hpp:12
fvar< T > exp(const fvar< T > &x)
Definition exp.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
#define STRINGIFY(...)
Definition stringify.hpp:9