Automatic Differentiation
 
Loading...
Searching...
No Matches
inv_logit.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT_HPP
2#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT_HPP
3#ifdef STAN_OPENCL
4
6#include <string>
7
8namespace stan {
9namespace math {
10namespace opencl_kernels {
11
12// \cond
13static constexpr const char* inv_logit_device_function
14 = "\n"
15 "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT\n"
16 "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT\n" STRINGIFY(
17 // \endcond
57 double inv_logit(double x) {
58 if (x < 0) {
59 if (x < log(DBL_EPSILON)) {
60 return exp(x);
61 }
62 return exp(x) / (1 + exp(x));
63 }
64 return 1.0 / (1 + exp(-x));
65 }
66 // \cond
67 ) "\n#endif\n"; // NOLINT
68// \endcond
69
70} // namespace opencl_kernels
71} // namespace math
72} // namespace stan
73
74#endif
75#endif
double inv_logit(double x)
Returns the inverse logit function applied to the kernel generator expression.
Definition inv_logit.hpp:57
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
fvar< T > exp(const fvar< T > &x)
Definition exp.hpp:13
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
#define STRINGIFY(...)
Definition stringify.hpp:9