Automatic Differentiation
 
Loading...
Searching...
No Matches
log_diff_exp.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_DIFF_EXP_HPP
2#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_DIFF_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* log_diff_exp_device_function
14 = "\n"
15 "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_DIFF_EXP\n"
16 "#define "
17 "STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_DIFF_EXP\n" STRINGIFY(
18 // \endcond
29 double log_diff_exp(double x, double y) {
30 if (x <= y) {
31 return (x < INFINITY && x == y) ? -INFINITY : NAN;
32 }
33 return x + log1m_exp(y - x);
34 }
35 // \cond
36 ) "\n#endif\n"; // NOLINT
37// \endcond
38
39} // namespace opencl_kernels
40} // namespace math
41} // namespace stan
42
43#endif
44#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
double log_diff_exp(double x, double y)
The natural logarithm of the difference of the natural exponentiation of x and the natural exponentia...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
#define STRINGIFY(...)
Definition stringify.hpp:9