Automatic Differentiation
 
Loading...
Searching...
No Matches
log1p_exp.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_EXP_HPP
2#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_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* log1p_exp_device_function
14 = "\n"
15 "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_EXP\n"
16 "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_EXP\n" STRINGIFY(
17 // \endcond
28 double log1p_exp(double a) {
29 // prevents underflow
30 return (a > 0 ? a : 0) + log1p(exp(-fabs(a)));
31 }
32 // \cond
33 ) "\n#endif\n"; // NOLINT
34// \endcond
35
36} // namespace opencl_kernels
37} // namespace math
38} // namespace stan
39
40#endif
41#endif
double log1p_exp(double a)
Calculates the log of 1 plus the exponential of the specified value without overflow.
Definition log1p_exp.hpp:28
fvar< T > log1p(const fvar< T > &x)
Definition log1p.hpp:12
fvar< T > fabs(const fvar< T > &x)
Definition fabs.hpp:16
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